Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!cmcl2!yale!husc6!think!rutgers!lll-crg!lll-lcc!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: comm '! sort file1' '! sort file2' Message-ID: <8086@sun.uucp> Date: Sat, 11-Oct-86 02:05:08 EDT Article-I.D.: sun.8086 Posted: Sat Oct 11 02:05:08 1986 Date-Received: Sat, 11-Oct-86 21:23:10 EDT References: <830003@hpcnoe.UUCP> <35@pixutl.UUCP> <3724@umcp-cs.UUCP> <264@desint.UUCP> <7028@elsie.UUCP> Organization: Sun Microsystems, Inc. Lines: 22 > 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@sun.com (or guy@sun.arpa)