sed parser doesn't recognize end of parameters .. bash-2.05b$ pwd | sed 's/\//\\\//g' \/home\/medic\/jobs\/scripts bash-2.05b$ TEST=`pwd | sed 's/\//\\\//g'` sed: -e expression #1, char 9: Unknown option to `s' bash-2.05b$ sed -V GNU sed version 4.0.7
That behaviour is correct, you should change the delimiter. TEST=`pwd | sed 's#\/#\\\/#g'`
the issue is your quoting ... if you change the `` to $() it works fine thus sed is not broken