Date: Thu, 06 Mar 1997 22:11:08 +0000 From: Brian Somers <brian@awfulhak.demon.co.uk> To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) Cc: spaz@u.washington.edu (John Utz), hackers@FreeBSD.ORG Subject: Re: awk bug? in 2.2 BETA? Message-ID: <199703062211.WAA24789@awfulhak.demon.co.uk> In-Reply-To: Your message of "Thu, 06 Mar 1997 21:18:02 %2B0100." <19970306211802.CZ51686@uriah.heep.sax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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.
Oops, so much for my opinion :(
--
Brian <brian@awfulhak.demon.co.uk>, <brian@freebsd.org>
<http://www.awfulhak.demon.co.uk/>
Don't _EVER_ lose your sense of humour....
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703062211.WAA24789>
