Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

/proc/nnn/fd/nnn and bash



   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!)




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org