[plug] Sed regex help

Brad Campbell brad at seme.com.au
Wed Jan 29 17:02:07 WST 2003


Cameron Patrick wrote:

>On Wed, Jan 29, 2003 at 04:43:31PM +0800, Brad Campbell wrote:
>
>| DOC2=`echo $DOC | sed s/\\\\/\//g`
>
>| What am I doing wrong. I'm sure I'm going to kick myself.
>
>I'm not sure why sed needs so many backslashes, but the simplest away around
>this problem is to use another delimeter so you don't have to escape the
>slashes, and make sure you use apostrophes so that bash doesn't get
>overenthusiastic.  Something like this should work:
>	DOC2=`echo "$DOC" | sed 's@\\\@/@g'`
>or if you like confusing regexes:
>	DOC2=`echo "$DOC" | sed 's/\\\/\\//g'`
>or if you are allergic to putting apostrophe's in the right place:
>	DOC2=`echo "$DOC" | sed s/\\\\\\\/\\\\//g`
>
>CP.
>  
>
Thanks for the quick response Tony, Ryan and Cameron.
The single quotes worked, number 3 above worked, and -e worked but only 
if I had single
quotes. the @ delimiter did not work and complained of an unterminated s 
command.
But my immediate problem is solved, thanks guys.
Now to dig myself an even deeper hole.

Brad :p)



More information about the plug mailing list