/proc/nnn/fd/nnn and bash
Dale R Worley
worley at world.std.com
Thu Aug 31 20:06:50 EDT 1995
From: Dan Demus <dan at Paragon.COM>
It seems like bash could use this to
implement the >(...) and <(...) "process substitution" mechanism, but
doesn't.
What it is really used for is to turn programs like cpio which aren`t
designed to be filters into filters.
Is process substitution just another PIPELINE notation?
No, what it does is set up a pipe to the parenthesized command(s), but
the other end of the pipe isn't attached to the containing command by
the usual mechanism, but rather by textually replacing the process
substitution with a file name. In the case of my Linux box, it is
something like "/tmp/sh-np-a01234", which is the name of a named
pipe that bash creates. (Bash also opens the named pipe and makes it
the standard input or standard output of the parenthesized
command(s).)
(Bash also screws up and makes the pipe world-readable if your umask
creates files that are world-readable.)
I think the advantage is that you can use the mechanism to accomplish
things that just couldn't be done by the ordinary pipe mechanism. For
instance, you can concatenate the output of several commands with:
cat <(pipeline 1) <(pipeline 2) <(pipeline 3) >file
You can take the difference of the output of two pipes with:
diff <(pipeline 1) <(pipeline 2)
Even uglier things can be accomplished.
Dale
Dale Worley worley at world.std.com
--
We have ways to make you scream.
-- Intel advertisement, in the June 1989 Doctor Dobbs Journal
(Yeah, like having to write 80x86 assembler code!)
More information about the Discuss
mailing list