Dup Goto 📝

ProcessSubstitution

PT2/aw/os/shell 07-31 13:46:42
To Pop
20 lines, 100 words, 611 chars Monday 2023-07-31 13:46:42

Process substitution is written using parentheses and behind the scenes uses named pipes.

Example 1

cat <(ls) <(echo hello)

This takes the command ls and sends its output to a named pipe (say pipe_a), does similar with the echo command, to say pipe_b, and then runs cat as

cat pipe_a pipe_b

The actual pipe filenames will look something like

/dev/fd/11

as you can verify by running e.g.

echo <(ls)

Note that this does //not// use stdin, and requires that the command (here cat) reads from files specified on the command line.