Skip to content

Instantly share code, notes, and snippets.

@guelau
Created April 12, 2018 13:45
Show Gist options
  • Save guelau/dd7ff03187ffab20c5c06f35cc3a5354 to your computer and use it in GitHub Desktop.
Save guelau/dd7ff03187ffab20c5c06f35cc3a5354 to your computer and use it in GitHub Desktop.
Reading ini file with Bash
#!/bin/bash
#
# Exemple:
# cat param.ini
# [PREPROD]
# host = masuperconf_preprod
# pass = motdepass_preprod
#
# [PRODUCTION]
# host = masuperconf_prod
# pass = motdepass_prod
#
MACONF=`sed -nr "/^\[PRODUCTION\]/ { :l /^host[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" ./param.ini`
echo $MACONF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment