[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OFS bug
From: |
Aharon Robbins |
Subject: |
Re: OFS bug |
Date: |
Sun, 10 Mar 2002 17:10:14 +0200 |
Greetings. Re this:
> Date: Sat, 9 Mar 2002 03:13:37 +0000 (WET)
> From: Nuno Miguel Fernandes Sucena Almeida <address@hidden>
> To: address@hidden
> Subject: OFS bug
>
> Hello,
>
> i think i found a bug:
>
> echo "a,b,c,d" | gawk 'BEGIN {FS=","} { OFS = ":"; $2 = ""; print
> $0; print NF }'
> a::c:d
> 4
>
> this is ok but the next:
>
> $echo "a,b,c,d" | gawk 'BEGIN {FS=","} { OFS = ":"; print $0; print NF }'
> a,b,c,d
> 4
>
> Shouldn't it be a:b:c:d ??
No. In the first case, you have modified one of the fields. The lone
`print' accesses the new value of $0, which, because you have modified a
field, forces $0 to be rebuilt using the new field separator.
In the second case, because you have not modified the record in any way,
the original record is printed as is.
Arnold
- OFS bug, Nuno Miguel Fernandes Sucena Almeida, 2002/03/08
- OFS bug, Nuno Sucena Almeida, 2002/03/09
- Re: OFS bug,
Aharon Robbins <=