process substitution
The bash form <(command), which runs a command and hands its output to another program as if it were a file name.
In more detail
It suits tools that insist on file names, such as diff and comm, as in diff <(sort a) <(sort b). Nothing is written to disk and nothing needs cleaning up, but the file can only be read once from start to end. Feeding a loop with done < <(command) keeps the loop in the current shell, unlike a pipe.
Example
comm -13 <(printf '200\n404\n') <(cut -d' ' -f4 access.log | sort -u)Related terms
- pipe — The | operator, which connects one command's standard output to the next command's standard input so they run together.
- subshell — A child copy of the current shell, created by ( ), by command substitution and by each stage of a pipe.
- diff — A listing of the differences between two versions of something, such as two files, two commits or two screenshots.
- comm — The command that compares two sorted files and prints lines unique to the first, unique to the second and common to both, in three columns.
Taught in
- Pipelines, tee And Process Substitution — Bash Scripting & Command Line Automation
- Command Substitution And Subshells — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation