[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed? escaping back slash
From: |
tt |
Subject: |
Re: sed? escaping back slash |
Date: |
08 Mar 2001 11:41:20 +0200 |
"Craig Allsop" <address@hidden> writes:
> Is this the correct behaviour for sed?
>
> echo test | sed "s/test/\\/"
>
> Under 4dos shell in Win98, Cygwin GNU version v1.18 gives: \
> Under 4dos shell in Win98, Cygwin GNU version v3.02 gives: char 9:
> Unterminated 's' command
I know nothing about 4dos shell but under Unix (POSIXy or Bourne) sh,
the latter is correct.
> As far as I can see in the documentation, I need only supply one
> back slash to escape a backspace in the replacement string.
Inside double quotes, shell will translate each \\ into \
before sed even sees them. Inside single quotes shell will
leave everything untouched. So the following are equivalent:
sed 's/test/\\/'
sed "s/test/\\\\/"
sed s/test/\\\\/
What 4dos shell will do I have no idea however.
One option always is putting the command
s/test/\\/
in a file and using sed -f file ...
--
Tapani Tarvainen