[olug] sed and sh
Jon H. Larsen
relayer at omahadirect.net
Wed Feb 5 13:06:02 UTC 2003
Would you believe I made a mistake in the code when I was merging parts of
two different scripts? I was defining the TRUNCFILE variable before I
defined the FILE variable. Such an obvious mistake on my part.
On Tue, 4 Feb 2003, Adam Haeder wrote:
> Date: Tue, 4 Feb 2003 16:32:57 -0600 (CST)
> From: Adam Haeder <adamh at omaha.org>
> Reply-To: olug at olug.org
> To: olug at olug.org
> Subject: Re: [olug] sed and sh
>
> Looks like you're running into a problem that plagues me often. I put
> together a nice sed regular expression match that works fine. Then I
> incorporate it into a script, and it doesn't work.
>
> When you put a sed script inside the backticks (`), you have to
> DOUBLE-ESCAPE everything. So if your original sed script was
> sed s/\\//i/g (which replaces all instances of / with i
> inside ticks it needs to be
> sed s/\\\//i/g
>
> Try it from a shell:
>
> [adamh at adam adamh]$ cat test
> this/this
> [adamh at adam adamh]$ cat test | sed s/\\//i/g
> thisithis
> [adamh at adam adamh]$ me=`cat test | sed s/\\//i/g`
> sed: -e expression #1, char 6: Unknown option to 's'
> [adamh at adam adamh]$ me=`cat test | sed s/\\\//i/g`
> [adamh at adam adamh]$ echo $me
> thisithis
> [adamh at adam adamh]$
>
>
> Strange but true.
>
>
--
[ Jon H. Larsen - email: relayer at omahadirect dot net ]
[ ICQ#: 10412618 - http://www.animesunday.org/jonl ]
[ PGP Pubkey - http://www.animesunday.org/jonl/relayerpubkey.txt ]
[ OpenOffice.org - Freedom at Work - http://www.openoffice.org ]
More information about the OLUG
mailing list