Sed to make global replacements.

Bruce Crabtree ssdbruce at jarthur.Claremont.EDU
Sat Dec 2 14:10:19 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'

By bracketing the backslash characters you are preventing sed from seeing
the '\(' combination.  Two backslashes are used since the backslash has
special meaning to sed and must be escaped (with another backslash).  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.  I added the 'g' or global option since I assume
you might have multiple occurrances of \(12 on a 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