From owner-freebsd-hackers Thu Mar 6 14:14:25 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id OAA15250 for hackers-outgoing; Thu, 6 Mar 1997 14:14:25 -0800 (PST) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id OAA15241 for ; Thu, 6 Mar 1997 14:14:18 -0800 (PST) Received: from awfulhak.demon.co.uk (localhost.lan.awfulhak.org [127.0.0.1]) by awfulhak.demon.co.uk (8.8.5/8.8.5) with ESMTP id WAA24789; Thu, 6 Mar 1997 22:11:08 GMT Message-Id: <199703062211.WAA24789@awfulhak.demon.co.uk> X-Mailer: exmh version 1.6.9 8/22/96 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? In-reply-to: Your message of "Thu, 06 Mar 1997 21:18:02 +0100." <19970306211802.CZ51686@uriah.heep.sax.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 06 Mar 1997 22:11:08 +0000 From: Brian Somers Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > 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 , Don't _EVER_ lose your sense of humour....