[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: escape characters in sed



On Mon, May 14, 2007 at 08:59:49AM -0700, Bob McGowan wrote:
> Hans du Plooy wrote:
> >william pursell wrote:
> >>Your version is missing the final ', so I'm guessing you
> >>meant: sed 's/\\)/ /' 
> >Yes, sorry, several mistakes on my part...
> >
> >>which will replace occurences
> >>of "\)" with a single space
> >Not what I had intended, I just wanted to replace ) with a space.  
> >Actually I wanted to replace the ( with a space and get rid of the 
> >trailing ),
> 
> So, you'd want to use:
> 
>   sed -e 's/(/ /' -e 's/)//'

any reason not to do 

sed -e 's/(/ /;s/)//'

> 
> Which says replace left parens with a space, right one with nothing, 
> with a single run of 'sed'.
> 
> >
> >>:  eg:
> >>$ echo '2nd backslash and first paren replaced: \\))' | sed 's/\\)/ /'
> >>2nd backslash and first paren replaced: \ )
> >>
> >>Note that this is exactly the same as:
> >>$ echo '2nd backslash and first paren replaced: \\))' | sed s/\\\\\)/\ /
> >>2nd backslash and first paren replaced: \ )
> >
> >Thanks, now I kinda understand why.
> >
> >Hans
> >
> >
> 
> Bob


Attachment: signature.asc
Description: Digital signature


Reply to: