[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sub("@\^","^",$0) doesn't
From: |
Aharon Robbins |
Subject: |
Re: sub("@\^","^",$0) doesn't |
Date: |
Fri, 20 Dec 2002 10:42:30 +0200 |
Greetings. Re this:
> From: "Clinton Wittstruck" <address@hidden>
> To: <address@hidden>
> Subject: sub("@\^","^",$0) doesn't
> Date: Thu, 19 Dec 2002 17:25:51 -0800
> Content-Transfer-Encoding: quoted-printable
>
> I've noticed a weird discrepency between awk on HP-UX 11.0 and Red Hat
> Linux 2.2.16-22 (GNU Awk 3.0.6 -- I also downloaded and tested gawk
> 3.1.1)
>
> For an occurance of "@^", substitue "^" -- (strip out the "@" before
> "^")
>
> I tried: sub("@\^","^",$0)
>
> On HP-UX awk this works but with gawk on Linux it does not.
You need an extra backslash in the string. For string constants,
you always need two backslashes to get sub/gsub to see one. This
is described in the gawk manual. Here is what I get:
$ echo here is an @^ | gawk '{ sub("@\\^", "^", $0); print }'
here is an ^
Thanks,
Arnold