comm '! sort file1' '! sort file2'
Jason Zions
jason at hpcnoe.UUCP
Thu Sep 25 07:27:28 AEST 1986
> / ado at elsie.UUCP (Arthur David Olson) / 8:20 am Sep 22, 1986 /
> I regularly want to run "comm" on a pair of unsorted files.
> [ ... ]
> 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.
You can do this more easily. Create a program, bang.c, the name of whose
executable is ! . All this sucker does is a mktemp, then executes the
rest of the command line as a command, redirecting stdout into the temporary
file. !'s output is just the name of the temporary file.
Admittedly, it's a bit dirty; the file isn't deleted, so /tmp could fill up
quick. Perhaps ! could fork; the child sleeps for 5 minutes, then unlinks
the temporary file. This depends on comm (or whatever) opening the temporary
file soon enough. You could make the 5 minutes into 1 hour and be pretty sure.
I would select some character other than ! as a command name; perhaps @. Not
sacred to any shell that I know of.
How's that?
--
This is not an official statement of Hewlett-Packard Corp., and does not
necessarily reflect the views of HP. It is provided completely without warranty
of any kind. Lawyers take 3d10 damage and roll a saving throw vs. ego attack.
Jason Zions Hewlett-Packard
Colorado Networks Division 3404 E. Harmony Road
Mail Stop 102 Ft. Collins, CO 80525
{ihnp4,seismo,hplabs,gatech}!hpfcdc!hpcnoe!jason
More information about the Comp.unix.wizards
mailing list