[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sub("@\^","^",$0) doesn't
From: |
cw02 |
Subject: |
Re: sub("@\^","^",$0) doesn't |
Date: |
Mon, 23 Dec 2002 09:41:02 -0800 (PST) |
Thanks! I confirmed that
sub("@\\^","^",$0)
works on HP-UX, Solaris and Linux.
> From address@hidden Sun Dec 22 00:52:59 2002
> Date: Fri, 20 Dec 2002 10:42:30 +0200
> From: Aharon Robbins <address@hidden>
> Message-Id: <address@hidden>
> To: address@hidden, address@hidden
> Subject: Re: sub("@\^","^",$0) doesn't
> 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
>