Sed to make global replacements.

Bruce Crabtree ssdbruce at jarthur.Claremont.EDU
Sat Dec 2 14:18:49 AEST 1989


In article <37090 at ames.arc.nasa.gov> gahooten at orion.arc.nasa.gov (Gregory A. Hooten) writes:
>I would like to change the characters \(12 to 1/2, but every thing I try
>thinks the \( is the start of a character group.

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

The brackets ('[]') are used to prevent sed from seeing the '\('
character combination and interpreting them as such.  Two backslashes
are used since the backslash must be escaped in sed.  The slash or
virgule in the '1/2' must also be escaped since sed would take it to
be the delimiter of the substitute command.  I've added the 'g' or
global option since I assume you might have more than one instance
of \(12 per line.

Bruce Crabtree

-- 
--------------------------------------------------------------------
Bruce Crabtree			      ssdbruce at jarthur.claremont.edu
Software Systems Design, Inc          [W] 1-714-624-2306
Claremont, CA                         [H] 1-714-738-6026



More information about the Comp.unix.questions mailing list