paperlined.org
apps > bash
document updated 21 days ago, on Jan 31, 2025
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:

Can this be done without writing the output to a temporary file?

Answer: YES!

The trick is to use Bash's process substitution feature:

Bash changes that into: It does that ^^^ after first running the two sort commands, and sending their output to filehandles 62 and 63.


You can write to subprocesses too:

That way, strace's output gets grepped, while leaving ./script_under_test.pl's STDOUT alone.

show me more!

Want to do more magic with process substitution? See the following examples: multitee is something else to look into

show me more!

There's lots of other I/O redirection tricks. [1] [2]