I have a string /tmp/testing which I want to replace with \/tmp\/testingsed works fine as follows:  echo testdir=/tmp/testing | sed 's/\//\\\//g'testdir=\/tmp\/testingHowever if I try and put this into a variable which I want to use later I get this error:myvar=`echo testdir=/tmp/testing | sed 's/\//\\\//g'`sed: -e expression #1, char 9: unknown option to `s'Any ideas please?
Replace / with \/
sed
Try this$ echo testdir=/tmp/testing | sed 's/\//\\\//g'testdir=\/tmp\/testingIn variablevar=$(echo testdir=/tmp/testing | sed 's/\//\\\//g')