bug-gnu-utils
[Top][All Lists]
Advanced

[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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]