Skip to content

Instantly share code, notes, and snippets.

@tadpol
Created December 17, 2020 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadpol/fb1fd25d14feb6f568d60378f6d4b217 to your computer and use it in GitHub Desktop.
Save tadpol/fb1fd25d14feb6f568d60378f6d4b217 to your computer and use it in GitHub Desktop.
# convert INI to sourcable env. (does not handle comments)
awk 'BEGIN {sec="default"}; /^\[/ {gsub(/\[|\]/,""); sec=$0} /=/ {print sec "_" $0}' < config.ini
# Filter in a single section (does not handle comments)
awk -v sec=dev 'BEGIN {nskip=0} /^\[.+\]$/ {if($0 == "[" sec "]") nskip=1; else nskip=0; next} nskip' < config.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment