Skip to content

Instantly share code, notes, and snippets.

@Gurpartap
Created May 6, 2012 15:28
Show Gist options
  • Save Gurpartap/2622921 to your computer and use it in GitHub Desktop.
Save Gurpartap/2622921 to your computer and use it in GitHub Desktop.
sed function with escaped keyword and replacement
function sedeasy {
sed -i "s/$(echo $1 | sed -e 's/\([[\/.*]\|\]\)/\\&/g')/$(echo $2 | sed -e 's/[\/&]/\\&/g')/g" $3
}
sedeasy "include /etc/nginx/conf.d/*" "include /apps/*/conf/nginx.conf" /etc/nginx/nginx.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment