[plug] Sed regex help

Cameron Patrick cameron at patrick.wattle.id.au
Wed Jan 29 16:49:38 WST 2003


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.



More information about the plug mailing list