How can I use /
in sed to find and replace as a normal /
and not a special charatcer.
Asked
Active
Viewed 385 times
-1

αғsнιη
- 41,407
-
1https://unix.stackexchange.com/questions/32907/what-characters-do-i-need-to-escape-when-using-sed-in-a-sh-script – John May 18 '18 at 02:29
1 Answers
2
sed
can use any other delimiter than slash, whatever comes after s
is treated as a delimiter
For eg: you can use a hash to replace slash by space
$ s#/# #g
Or you can use ? to replace / by space
$ s?/? ?g
Or any other delimiter of your choice
Or you can escape / by using backslash
$ s/\// /g
-
It's not GNU specific, any
sed
can do that. Same ined
(where thats|...|...|
comes from in the late 60s), orex
/vi
orperl
. – Stéphane Chazelas May 18 '18 at 07:48