Skip to main content

I should suppose you are talking about bash or some other advanced shell, because the posix shell dodoes not have process substitution.

bash manual page reports:

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.

When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.

In other words, and from a practical point of view, you can use an expression like the following

<(commands) 

as a file name for other commands requiring a file as a parameter. Or you can use redirection for such a file:

while read line; do something; done < <(commands) 

Turning back to your question, it seems to me that process substitution and pipes have not much of similarin common.

If you want to pipe in sequence the output of multiple commands, you can use one of the following forms:

(command1; command2) | command3 { command1; command2; } | command3 

but you can also use redirection on process substitution

command3 < <(command1; command2) 

finally, if command3 acceptaccepts a file parameter (in substitution odof stdin)

command3 <(command1; command2) 

I should suppose you are talking about bash or some other advanced shell, because the posix shell do not have process substitution.

bash manual page reports:

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.

When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.

In other words, and from a practical point of view, you can use an expression like the following

<(commands) 

as a file name for other commands requiring a file as a parameter. Or you can use redirection for such a file:

while read line; do something; done < <(commands) 

Turning back to your question, it seems to me that process substitution and pipes have not much of similar.

If you want to pipe in sequence the output of multiple commands you can use one of the following forms:

(command1; command2) | command3 { command1; command2; } | command3 

but you can also use redirection on process substitution

command3 < <(command1; command2) 

finally, if command3 accept a file parameter (in substitution od stdin)

command3 <(command1; command2) 

I should suppose you are talking about bash or some other advanced shell, because the posix shell does not have process substitution.

bash manual page reports:

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.

When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.

In other words, and from a practical point of view, you can use an expression like the following

<(commands) 

as a file name for other commands requiring a file as a parameter. Or you can use redirection for such a file:

while read line; do something; done < <(commands) 

Turning back to your question, it seems to me that process substitution and pipes have not much in common.

If you want to pipe in sequence the output of multiple commands, you can use one of the following forms:

(command1; command2) | command3 { command1; command2; } | command3 

but you can also use redirection on process substitution

command3 < <(command1; command2) 

finally, if command3 accepts a file parameter (in substitution of stdin)

command3 <(command1; command2) 
Source Link
enzotib
  • 53.5k
  • 14
  • 126
  • 106

I should suppose you are talking about bash or some other advanced shell, because the posix shell do not have process substitution.

bash manual page reports:

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.

When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion.

In other words, and from a practical point of view, you can use an expression like the following

<(commands) 

as a file name for other commands requiring a file as a parameter. Or you can use redirection for such a file:

while read line; do something; done < <(commands) 

Turning back to your question, it seems to me that process substitution and pipes have not much of similar.

If you want to pipe in sequence the output of multiple commands you can use one of the following forms:

(command1; command2) | command3 { command1; command2; } | command3 

but you can also use redirection on process substitution

command3 < <(command1; command2) 

finally, if command3 accept a file parameter (in substitution od stdin)

command3 <(command1; command2)