Created
April 12, 2018 13:45
-
-
Save guelau/dd7ff03187ffab20c5c06f35cc3a5354 to your computer and use it in GitHub Desktop.
Reading ini file with Bash
This file contains 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
#!/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