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
You can write to subprocesses too:
# list all .so libraries that are loaded when a Perl script runs strace -e trace=open,openat -o >( grep '\.so' | grep -v ENOENT ) ./script_under_test.plThat way, strace's output gets grepped, while leaving ./script_under_test.pl's STDOUT alone.