To implement
command1 | command2
, the shell creates a channel in the parent process and attaches one end to the output (fd 1; uses dup or dup2) of command 1, and the other end of the input (fd 0) of command 2.
To implement
command1>> (command 2)
, the shell creates a FIFO. It attaches command2 to the FIFO file (usually open using the O_WRONLY flag) and passes the FIFO name as a positional argument to command1. You can easily see this using
echo >(true) .
If you use
>> (foo)
, these forms are really very similar. However, the process subsection mechanism is more efficient. For example, you do things like this:
diff -u <(curl 'http://www.a.example.com/') <(curl 'http://www.b.example.com/')
You cannot do this with pipes - you cannot have two standard inputs.
source share