Skip to content

Instantly share code, notes, and snippets.

@kongchen
Last active January 3, 2023 09:29
Show Gist options
  • Select an option

  • Save kongchen/6748525 to your computer and use it in GitHub Desktop.

Select an option

Save kongchen/6748525 to your computer and use it in GitHub Desktop.
set properties file value by key via bash shell
#!/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"
@gopisettypradeep
Copy link
Copy Markdown

Can you explain about the scripts with details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment