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

Re: escape characters in sed



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/)//'

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: smime.p7s
Description: S/MIME Cryptographic Signature


Reply to: