Skip to content

peter-d/config-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

config-parser

Configuration (ini style) parser in Bash

About

This script is freely inspired by bash ini parser from ajdiaz. It's a fast way to parse an ini-style configuration file and to load the variables in your main script.

License

This script is under the MIT License. See LICENSE file.

Dependencies

config-parser.sh uses sed to parse the ini file.

Usage

Just include config-parser.sh in your code, and then call it:

# parse the configuration file
config_parser "/path/to/config/file.ini";
# load <my_section> from the ini file
config.section.<my_section>;

INI File example

[dev]
foo="bar";
foofoo="foo";
foofoofoo="$foofoo $foo";

[prod]
foo="foo";
foofoo="bar";
foofoofoo="$foofoo $foo";

If we run the following code against this example:

config_parser "/path/to/example/file.ini";
config.section.dev;
echo "$foofoofoo";
config.section.prod;
echo "$foofoofoo";

We'll get this output:

foo bar
bar foo

About

Configuration (ini style) parser in Bash

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%