Date: Thu, 6 Mar 1997 21:18:02 +0100 From: j@uriah.heep.sax.de (J Wunsch) To: spaz@u.washington.edu (John Utz) Cc: hackers@FreeBSD.ORG Subject: Re: awk bug? in 2.2 BETA? Message-ID: <19970306211802.CZ51686@uriah.heep.sax.de> In-Reply-To: <Pine.OSF.3.95.970306101744.11587E-100000@becker1.u.washington.edu>; from John Utz on Mar 6, 1997 10:23:34 -0800 References: <Pine.OSF.3.95.970306101744.11587E-100000@becker1.u.washington.edu>
index | next in thread | previous in thread | raw e-mail
As John Utz wrote:
> mira: {60} cat fd1.dat | awk 'BEGIN { FS = " " }; END { printf "rf= %g; cf
> = %g\n;", NR, NF }'
>
> rf= 9801; cf = 0;
>
> cf should be 3!
>
> fd1.dat has 9801 lines and 3 colums of data, and this awk is not reporting
> the columns....
NF The number of fields in the current record. Inside a
BEGIN action, the use of NF is undefined unless a getline
function without a var argument is executed previously.
Inside an END action, NF shall retain the value it had for
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the last record read, unless a subsequent, redirected,
^^^^^^^^^^^^^^^^^^^^
getline function without a var argument is performed prior
to entering the END action.
Our version of awk breaks this. It resets NF to 0 before the EOF is
seen.
--
cheers, J"org
joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970306211802.CZ51686>
