Skip to content

Instantly share code, notes, and snippets.

@webflo-dev
Last active June 29, 2020 18:08
Show Gist options
  • Save webflo-dev/28851f55f618518909b4cdad1e14c065 to your computer and use it in GitHub Desktop.
Save webflo-dev/28851f55f618518909b4cdad1e14c065 to your computer and use it in GitHub Desktop.
read ini file using shell script
# 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