Last active
June 29, 2020 18:08
-
-
Save webflo-dev/28851f55f618518909b4cdad1e14c065 to your computer and use it in GitHub Desktop.
read ini file using shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all [sections] of a .INI file | |
sed -n 's/^[ \t]*\[\(.*\)\].*/\1/p' $ini_file | |
# Read KEY from [SECTION] | |
sed -n '/^[ \t]*\[SECTION\]/,/\[/s/^[ \t]*KEY[ \t]*=[ \t]*//p' | |
# Read all values from SECTION in a clean KEY=VALUE form | |
sed -n '/^[ \t]*\[SECTION\]/,/\[/s/^[ \t]*\([^#; \t][^ \t=]*\).*=[ \t]*\(.*\)/\1=\2/p' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment