[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk "\\" "(" strange behavior ...
From: |
Ralph Corderoy |
Subject: |
Re: gawk "\\" "(" strange behavior ... |
Date: |
Tue, 07 Sep 2004 08:23:47 GMT |
Hi Jeff,
See Stepan's reply for the real answer.
> Can someone please explain why I've to use /\\/ instead of "\\" to
> substitute "backslash" into "b" ...
>
> this works ...
> echo "\\" | awk '{print $0; gsub(/\\/, "b"); print $0;}'
>
> this doesn't ...
> echo "\\" | awk '{print $0; gsub("\\", "b"); print $0;}'
If you really need a constant string in the awk script at that point,
you need to allow for the extra interpretation.
$ echo "\\" | awk '{gsub("\\\\", "b")}1'
b
$ echo | awk '{print "\\", "\\\\"}'
\ \\
$
Cheers,
--
Ralph Corderoy. http://inputplus.co.uk/ralph/ http://troff.org/
Re: gawk "\\" "(" strange behavior ..., Andreas Schwab, 2004/09/07
- Re: gawk "\\" "(" strange behavior ...,
Ralph Corderoy <=