Awk strangeness or misunderstandings?
James E. Leinweber
jiml at uwslh.slh.wisc.edu
Fri May 3 02:23:03 AEST 1991
ericw at janis.UUCP (Eric Wedaa) writes:
>I've been having some troubles with awk under Ultrix 3.0 and 3.1. ...
> awk '{system("date")}' test.file ... produces NO output.
Under Ultrix 4.1 on a Vaxstation 3100 and 4.3BSD Unix on an 11/750, I get:
(/usr/1/wbacti) sente$ awk 'END{print system("date")}' < /dev/null
date
(/usr/1/wbacti) sente$ nawk 'END{print system("date")}' < /dev/null
Thu May 2 11:15:14 CDT 1991
0
Consulting the documentation we have on the old and new awks, it appears
that the system() function was one of the 1985 additions. Old awk evaluates
system("date") as a concatenation of an uninitialized variable named
"system" with a string "date". Since concatenation is implicit and so
is variable initialization, this surprising behavior is required by the
language definition.
The solution is to get a recent version of awk. Upgrading to Ultrix
4.1 is one way; failing that I'd suggest getting the GNU awk clone
"gawk" from your nearest comp.sources archive or the FSF.
--
Jim Leinweber (608)262-0736 State Lab. of Hygiene/U. of Wisconsin - Madison
jiml at sente.slh.wisc.edu uunet!uwvax!uwslh!jiml fax:(608)262-3257
More information about the Comp.unix.ultrix
mailing list