Compare Command Output With Process Substitution
Feed the output of two commands directly into diff or other file readers.
Run diff <(sort a.txt) <(sort b.txt) to compare the two sorted streams.
01Command
Command
$ diff <(sort a.txt) <(sort b.txt)02What it does
Process substitution <(cmd) presents a command's output as a filename, so tools that only accept files can consume live command output. That avoids scratch files and keeps pipelines reproducible, which is a scripting advantage no GUI file compare offers.
03Risk
!Warning: Process substitution is a bash/zsh feature; POSIX sh needs a temporary file instead.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- bash.1.en.html manual pageEvidence: The bash manual page documents process substitution.
Last verified: 2026-10-13 · Category: Developer