3

tldp lists two syntaxes for process substitution. >(command_list) and <(command_list)

What is the difference, if any?

1
  • 1
    The fact that tldp presents both forms without explaining the difference illustrates how bad a reference tldp is. Aug 14, 2015 at 3:05

1 Answer 1

5

Yes, a significant difference. See http://www.gnu.org/software/bash/manual/bashref.html#Process-Substitution

Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of

<(list)

or

>(list)

The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list. Note that no space may appear between the < or > and the left parenthesis, otherwise the construct would be interpreted as a redirection.

Examples: comm requires input files to be sorted:

comm <(sort file1) <(sort file2)

Usage of >(cmd) is less frequent. I typically only use it with tee to send some output to various pipelines

seq 10 | tee >(rev > out1) >(tac > out2) >(shuf > out3)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .