Process substitution

Syntax

command_1 <( command_2 )

Run command_2 with its output connected to a named pipe (or an open file in /dev/fd) and place the file’s name in the argument list of command_1.

command_1 >( command_2 )

Run command_2 with its input connected to a named pipe (or an open file in /dev/fd) and place the file’s name in the argument list of command_1.

Examples

# sort two files and present the differences between the results using the diff
# command

diff <(sort file_1) <(sort file_2)
# compare two MD5 checksum files generated by 'md5deep'

diff <(cat file_1.md5 | awk -F"/" '{print $1 $NF}' | sort -k2) \
     <(cat file_2.md5 | awk -F"/" '{print $1 $NF}' | sort -k2)
# compare two web files

diff -s <(curl https://site_1/file_1) <(curl https://site_2/file_2)

2020–07–14