Process substitution

We know that we can use a pipe to provide the output of a command as an input to another command. For example:

$ cat file.txt | less

Here, the cat command output—that is, the content of file.txt—is passed to the less command as an input. We can redirect the output of only one process (cat process in this example) as an input to another process.

We may need to feed the output of multiple processes as an input to another process. In such a case, process substitution is used. Process substitution allows a process to take the input from the output of one or more processes rather than a file.

The syntax of using process substitution is as follows:

To substitute input file(s) by list

<(list)

OR

To substitute output file(s) by list

Get Linux Shell Scripting Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.