Shell tips and tricks (was: cat pipe)

Ben Scott dragonhawk at gmail.com
Fri Oct 5 10:04:08 EDT 2007


On 10/4/07, Michael ODonnell <michael.odonnell at comcast.net> wrote:
> Bash users can do this:
>
>    cp <( date ) /dev/tty

  I had to look that up.  "Process Substitution".  Assuming I
understand correctly, that connects the output of the "date" command
to a named pipe (say, /tmp/foo), and then substitutes the name of said
pipe for the actual argument.  So after substitution, the command
would look like:

	cp /tmp/foo /dev/tty

  Obviously, your example is a pointless example, but even so... I'm
trying to think what possible use this would be.  Why would you want
to use Process Substitution for real?

  The only thing I could think of would be for lame programs which
insist on read/writing to a named file, and will not use stdin/stdout
in the manner of a Unix filter.  But I've always just done:

	foo | lameprog /dev/stdin

or whatever for such cases.

-- Ben


More information about the gnhlug-discuss mailing list