Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!nike!ucbcad!ucbvax!ulysses!ggs From: ggs@ulysses.UUCP (Griff Smith) Newsgroups: net.unix-wizards Subject: Re: comm '! sort file1' '! sort file2' Message-ID: <1398@ulysses.UUCP> Date: Wed, 24-Sep-86 13:09:18 EDT Article-I.D.: ulysses.1398 Posted: Wed Sep 24 13:09:18 1986 Date-Received: Wed, 24-Sep-86 22:14:11 EDT References: <6846@elsie.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 52 > I regularly want to run "comm" on a pair of unsorted files. So I ended up > writing a shell script to do the job, the guts of which (simplified for the > purposes of this article) is: > > tmp=/tmp/\#scomm.$$ > sort "$1" > $tmp > sort "$2" | comm $tmp - > rm $tmp > > All fine and dandy. But then I got to thinking. . .that what I'd *really* > like to be able to do is use a command like > > comm '! sort file1' '! sort file2' > > (where the space after the '!' should be your clue that I use csh) and have > comm do the dirty work. > > And then I got to thinking. . .that if fopen turned > fopen("!whatever", "r") > calls into > popen("whatever", "r") > calls (with other changes as necessary), then what I'd like to see happen > with the "comm" command would happen generally. > > Comments? > -- > UNIX is a registered trademark of AT&T. > -- > UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA > DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks. And then I get to re-build all the commands with the new library. This is exactly what the shell was designed to avoid! Such features belong in the shell! The Korn shell supports the syntax comm <(sort file1) <(sort file2) The expression "<(sort file1)" turns into /dev/fd/n, where "n" is the file descriptor number for the pipe. True, this only works on V8 and on systems that have had the /dev/std{in,out,err} feature added to the kernel, but it is a much cleaner solution. Then I get to worry about diff <(sort file1) <(sort file2) which fails because diff can't seek on the pipe. -- Griff Smith AT&T (Bell Laboratories), Murray Hill Phone: (201) 582-7736 UUCP: {allegra|ihnp4}!ulysses!ggs Internet: ggs@ulysses.uucp