For some reason I need to escape forward slash inside some string
# echo "http://google.com" | sed -e 's/[/]/\\\//g'
http:\/\/google.com
But when I try to execute the same inside “ it shows me:
# somevar=`echo "http://google.com" | sed -e 's/[/]/\\\//g'`
sed: -e expression #1, char 10: unknown option to `s'
My sed’s version:
# rpm -q sed
sed-4.1.5-8.el5
This is because the inside the backticks (aka backquotes, grave accents),
\\is replaced with\before the command is parsed.From the bash manpage:
Just use
$(...)instead of backticks, unless you really need pre-posixshcompatibilityI’d also recommend using a regex delimiter other than
/to make this easier, e.g.