I want to use sed to change a slash into a backslash and a slash, i.e. / -> \/. But it does not work. Here a small example:
#!/bin/bash
TEST=/etc/hallo
echo $TEST
echo $TEST | sed "s/hallo/bello/g"
echo $TEST | sed "s/\//\\\//g"
The output of the first three lines is as assumed. But the last one does not work. Why? How to correct the last part?
echo sed "s/\//\\\//g"->sed s/\//\\//g. Btw you can use something else for sed, like's@/@\\/@g'. – Mingye Wang Jun 24 '15 at 13:28