Use a command's output as a file
<(cmd) turns a command's stdout into a file path the next program can read. Useful for tools like diff that take filenames, not pipes.
Compare two command outputs
diff <(ls dir1) <(ls dir2)
diff <(sort a.txt) <(sort b.txt)
comm -23 <(sort users-now.txt) <(sort users-yesterday.txt)None of these need temp files. Bash creates a FIFO under /dev/fd/63 behind the scenes; the consumer reads from it as if it were a real file.
Outbound: >(cmd)
some_cmd >(gzip > out.gz) 2> errors.log
tar c -f >(ssh remote 'cat > backup.tar') /homeLess common but powerful: a command writes to a path; the path is actually another command's stdin.
Why not just use a pipe?
Pipes only have one input. Process substitution lets you feed two or more inputs into a tool that expects file arguments. It's the natural shape for diff / comm / paste / join.
Doesn't work in POSIX sh
Process substitution is a bash/zsh extension. POSIX sh scripts need temp files (mktemp) for the same job. Yet another reason to write modern scripts in bash, not sh.