Sed to make global replacements.

Guy Harris guy at auspex.auspex.com
Sat Dec 9 05:40:53 AEST 1989


>Try
>                sed 's/[\\](12/1\/2/g'

or just

                 sed 's/\\(12/1\/2/g'

since, as you note:

>Two backslashes are used since the backslash has special meaning to sed
>and must be escaped (with another backslash).

so escaping the backslash with another one is sufficient.  (Yes, I tried
it.)  In addition

>The slash (or virgule, if you will) that is used to separate the '1/2' must
>also be escaped to prevent sed from using it as the delimiter of the 
>substitution command.

Or you can do

                 sed 's;\\(12;1/2;g'

using ";" as the delimiter, or any other character.



More information about the Comp.unix.questions mailing list