This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Shell Process Substitution & Named Pipes Cheatsheet

A quick reference guide for Shell process substitution and FIFO named pipes: mkfifo, <(command) syntax, and inter-process streaming.

· Published

Process substitution and FIFO named pipes allow passing standard output streams between commands as if they were regular filesystem files.

Process Substitution (<() and >())

Process substitution feeds the output of a subshell into a command expecting file path arguments:

# Compare the output of two commands without writing temporary files
diff <(ls ./old_dir) <(ls ./new_dir)

# Compare sorted files directly
diff <(sort file1.txt) <(sort file2.txt)

# Stream command output to compression and hash simultaneously
tee >(gzip > data.gz) >(sha256sum > data.sha) < large_file.tar

FIFO Named Pipes (mkfifo)

A FIFO (First-In-First-Out) special file provides a persistent named pipe on the filesystem:

# 1. Create a named pipe file
mkfifo mypipe

# 2. In Terminal 1 (Consumer blocks until writer connects)
cat < mypipe

# 3. In Terminal 2 (Producer writes to pipe)
echo "Hello via pipe" > mypipe

# 4. Remove the named pipe when done
rm mypipe

References

Related topics