Using pipes within awk programs

Carl M. Fongheiser cmf at cisunx.UUCP
Sat Jan 23 12:19:59 AEST 1988


In article <20466 at teknowledge-vaxc.ARPA> mkhaw at teknowledge-vaxc.ARPA (Mike Khaw) writes:
]>> >	who | awk '{ print $1 | "sort" }'
]
]>> >	who | awk '{ print $1 }' | sort
]
]>> FYI, the two *don't* give the same results under Ultrix T2.0-1I.
]
]> Then Ultrix must be seriously broken, to not allow standard
]
]I think Ultrix awk is older than 4.3bsd's "old" awk.  On Ultrix 1.2,
]the first form of pipe prints nothing.  The second form prints a sorted
]list of logged in users.  Ultrix 1.2's awk also has the bug where
]things like
]
]	echo foo bar | awk '{ tmp = $1; $1 = $2; $2 = tmp; print $1, $2 }'
]
]don't work.  That's how old it is.
]
]Mike Khaw

That's funny -- I just tried these commands under both Ultrix 1.2 and 2.0.
They worked fine!  Incidentally, there is a difference between the
first two commands.  On Ultrix, the output of sort appears asynchronously
when sort is started by awk -- as if awk didn't do a wait() on the process.

				Carl Fongheiser
				University of Pittsburgh
				Computing & Information Systems
				...!pitt!cisunx!cmf
				cmf at pittvms.BITNET
				cmf%vms.cis.pittsburgh.edu at vb.cc.cmu.edu



More information about the Comp.unix.questions mailing list