Often I want to diff the output of two COMMANDS. That is, I want to run command A, then run command B, then diff the output of both of those.
For example:
sort file1 > file1.sorted sort file2 > file2.sorted diff file1.sorted file2.sorted
Can this be done without writing the output to a temporary file?
Answer: YES!
The trick is to use Bash's process substitution feature:
diff <(sort file1) <(sort file2)Bash changes that into:
diff /dev/fd/63 /dev/fd/62