Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mhuxt!mhuxm!mhuxo!ulysses!allegra!mit-eddie!husc6!think!ames!aurora!labrea!decwrl!decvax!ima!minya!jc From: jc@minya.UUCP Newsgroups: comp.unix.questions Subject: Re: Using pipes within awk programs Summary: nor on Sys/V.2 Keywords: awk, pipe Message-ID: <455@minya.UUCP> Date: 23 Jan 88 16:41:02 GMT References: <515@root44.co.uk> <2138@geac.UUCP> Organization: home Lines: 37 In article <2138@geac.UUCP>, ivor@geac.UUCP (Ivor Williams) writes: > 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. Nor on this Sys/V machine, and I am rather mystified at the difference. The second produces output like I expect. My prompt is set up to show the current directory, so what I see on my screen when I use the second command is: | /usr/jc: who | awk '{ print $1 }' | sort | jc | std | /usr/jc: However, when I try the first command, the screen looks like: | /usr/jc: who | awk '{ print $1 | "sort" }' | /usr/jc: jc | std In other words, I get a new shell prompt, and THEN I get the output from the command. There was no '&' anywhere in the line. Does anyone have an explanation as to why the output was delayed like this? It looks like awk is starting the sub-process and exiting without waiting for it to complete. I find this a bit surprising, not to mention a bit weird. Consider also: | /usr/jc: who | awk '{ print $1 | "sort" }' |wc | 2 2 7 This appears to work correctly, so I clearly don't understand what's going on here. -- John Chambers <{adelie,ima,maynard,mit-eddie}!minya!{jc,root}> (617/484-6393)