Tobias Brunner bio photo

Tobias Brunner

...(a.k.a. tobru) is a Network and Linux Engineer (LPIC-2), working at VSHN AG and blogs about DevOps, Networking, Linux and OpenSource topics on his techblog tobrunet.ch.

Email Twitter XING Github Flattr this

Comparing two files with the diff utility is an easy task:

diff <file1> <file2>

But if you want to compare the output of two commands without temporarily saving it to a file, it’s a bit more complicated, because diff needs two inputs:

diff -u <(echo output1) <(echo output2)
--- /proc/self/fd/11    2013-07-29 10:59:06.037561642 +0200
+++ /proc/self/fd/12    2013-07-29 10:59:06.037561642 +0200
@@ -1 +1 @@
-output1
+output2

As we can see, the shell creates two file-descriptors from the stdin input.