Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!uwm.edu!uwvax!uwslh!jiml From: jiml@uwslh.slh.wisc.edu (James E. Leinweber) Newsgroups: comp.unix.ultrix Subject: Re: Awk strangeness or misunderstandings? Keywords: awk Message-ID: <1991May2.162303.10658@uwslh.slh.wisc.edu> Date: 2 May 91 16:23:03 GMT References: <115@janis.UUCP> Organization: Wisconsin State Laboratory of Hygiene Lines: 25 ericw@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@sente.slh.wisc.edu uunet!uwvax!uwslh!jiml fax:(608)262-3257