Created
May 6, 2012 15:28
-
-
Save Gurpartap/2622921 to your computer and use it in GitHub Desktop.
sed function with escaped keyword and replacement
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
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