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

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

Re: An issue about gwak 3.1.1, is it a bug?


From: Aharon Robbins
Subject: Re: An issue about gwak 3.1.1, is it a bug?
Date: Thu, 06 Sep 2007 18:26:56 +0300

Greetings. Sorry for the delay in replying to this.

This is discussed in the gawk documentation, although I can't find it at
the moment. The upshot is that the record is already split by the
time the assignment to FS happens.  You should use

        awk -F'\t' ...

or

        awk 'BEGIN { FS = "\t" } ; ... '

to get what you want.

Also, 3.1.1 is very, Very, VERY old. The current version is 3.1.5, and
there is a CVS archive on savannah.gnu.org which is even more current.
You should definitely upgrade.

Thanks,

Arnold

> Date: Mon, 23 Jul 2007 15:22:20 +0800
> From: =?gb2312?B?uN/A2g==?= <address@hidden>
> Subject: An issue about gwak 3.1.1, is it a bug?
> To: address@hidden
>
> Hi,
>
> Here is an issue of gawk, may be a bug :
>
> SYS: Linux 2.4.31-2bs #2 SMP Wed Mar 22 11:39:55 CST 2006 i686 i686 i386
> GNU/Linux
>
> GWAK: GNU Awk 3.1.1
>
> I have a file named a.log,(the delimiter is Tab)
>
> $ cat a.log
> 1abc    2abc
> 3abc    4abc
> 5abc    6abc
>
>
> And then I wrote a command as:
>
> $ awk 'FS="\t" gsub(/a/,"A",$1){print $0,NF}' a.log
> 1Abc 2abc 2
> 3Abc    4Abc 1
> 5Abc    6Abc 1
>
> Why this? The delimiter of first line is space, but other lines is Tab)
>
>  
>
> I know the ¡°FS=¡± is invalible,
>
> but such command¡¯s result is right:
>
> $ awk '{FS="\t"; gsub(/a/,"A",$1);print $0,NF}' a.log
> 1Abc 2abc 2
> 3Abc 4abc 2
> 5Abc 6abc 2
>
> I guess there is something wrong between ¡°FS=¡± and > ¡°gsub¡±.
>
> I am glad to receive any reply, thanks
>
> Yours,
>
> Gaolei 





reply via email to

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