-
-
Save hasanmohdkhan/824def52fbc46f470044e7ad23ba4f69 to your computer and use it in GitHub Desktop.
set properties file value by key via bash shell
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
#!/bin/bash | |
############################ | |
#script function | |
############################ | |
setProperty(){ | |
awk -v pat="^$1=" -v value="$1=$2" '{ if ($0 ~ pat) print value; else print $0; }' $3 > $3.tmp | |
mv $3.tmp $3 | |
} | |
############################ | |
### usage: setProperty $key $value $filename | |
setProperty "store.folder" "/opt/current/store" "env.properties" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment