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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: $x bug


From: Aharon Robbins
Subject: Re: $x bug
Date: Thu, 4 Sep 2003 16:25:21 +0300

Greetings.  Re this:

> Date: Thu, 04 Sep 2003 14:59:21 +0200 (MET DST)
> Organization: Robert Bosch GmbH
> From: Christoph Moser <address@hidden>
> To: address@hidden
> Subject: $x bug
>
> Hi.
>
>
>   > echo "5,4;4,6;6,7" | gawk -F ";" '{gsub(/,/,"§",$1);print $0}'
>   5§4 4,6 6,7
>   > echo "5,4;4,6;6,7" | gawk -F ";" '{gsub(/\,/,"§",$1);print $0}'
>   5§4 4,6 6,7
>   > echo "5,4;4,6;6,7" | gawk -F ";" '{gsub(/[,]/,"§",$1);print $0}'
>   5§4 4,6 6,7
>   > echo "5,4;4,6;6,7" | gawk -F ";" '{gsub(/[\,]/,"§",$1);print $0}'
>   5§4 4,6 6,7
>
> I think this is a bug. The result should be
>
>   5§4;4,6;6,7

No, it's not a bug.  Once $1 has changed, the original record is
no longer valid.  Thus, when you want to print $0, gawk reconstitutes
it by concatenting the fiels, separated by OFS.  If you set

        OFS = ";"

in the BEGIN block or with -v, you should get what you want.

Thanks,

Arnold




reply via email to

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