The process substitution
The process substitution is a handy way to feed the of multiple commands/processes to the input of another process. The standard way to manage a process substitution goes along with the following syntax:
>(list_of_commands) <(list_of_commands)
Mind the space between <
,>
, and the parentheses; there is no space at all:
zarrelli:~$ wc -l <(ps -fj) 5 /dev/fd/63
In this example, the output of ps -fj
has been given as an input to wc -l
, which counted 5
lines in the output. Notice/dev/fd/63
.
This is the file descriptor used by the process substitution to feed the results of the process inside the parentheses to another process. So, file descriptors in /dev/fd
are used to feed data, and this is useful, especially for those commands that cannot take advantage of pipes, because they expect data to be read from a file and not fed from the standard input. A classic example of a multiprocess feed as follows:
zarrelli:~$ mkdir "test 1" zarrelli:~$ mkdir "test 2" zarrelli...