comm '! sort file1' '! sort file2'
Guy Harris
guy at sun.uucp
Sat Oct 11 16:05:08 AEST 1986
> Think of the havoc that results if I put a
> sort "$1" > ~/fifo & sort "$2" | comm - ~/fifo
> command into a shell script (named, for example, "scomm") and then,
> six months from now when I've forgotten the implementation details,
> type in
> scomm firstfile secondfile > results &
> scomm thirdfile fourthfile > moreresults &
At which point you say "Since the FIFO is a temporary file, I shouldn't just
save a FIFO in my home directory for a rainy day and use that; I should
create it at the beginning of the script, using "$$" in the name to make the
name unique, and delete it at the end!" and change the script to read like:
fifoname=/tmp/scomm.$$
trap "rm -f $fifoname; exit 1" 1 2 15
/etc/mknod $fifoname p
sort "$1" > $fifoname & sort "$2" | comm - $fifoname
rm -f $fifoname
--
Guy Harris
{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
guy at sun.com (or guy at sun.arpa)
More information about the Comp.unix.wizards
mailing list