Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucsd!ucsdhub!hp-sdd!hplabs!hpcea!hpda!hpcupt1!davel From: davel@hpcupt1.HP.COM (Dave Lennert) Newsgroups: comp.unix.questions Subject: Re: 4.2BSD awk bugs (was Re: Using pipes within awk programs) Message-ID: <6060005@hpcupt1.HP.COM> Date: 31 Jan 88 05:20:27 GMT References: <515@root44.co.uk> Organization: Hewlett Packard, Cupertino Lines: 26 > In article <515@root44.co.uk> you write: > > who | awk '{ print $1 | "sort" }' > >gives the same output as > > who | awk '{ print $1 }' | sort > > FYI, the two *don't* give the same results under Ultrix T2.0-1I. One explanation could be that early versions of awk (e.g., 4.2) do not wait for all their children to finish before exiting. So, in the first example above, the awk could finish while the sort is running. If stdout is a terminal and BSD job control is active and the LTOSTOP flag is set, then you won't see any (or complete) output since the sort will be killed when it attempts output as a background, orphaned process. If stdout is a file, then the user (or the next command in the script) could examine the file before it is completely written by sort. Now you know why all my scripts look like: who | awk '{ print $1 | "sort" }' > tmp sleep 60 # hack for awk cat tmp -Dave Lennert HP ihnp4!hplabs!hpda!davel