How to do an N-way diff

diff()scripting

How do I diff the output of multiple commands? vimdiff can support up to four files, but diff itself seems to support exactly two files.

Is it directly possible with some variant of diff, or do I have to save the output of all commands to temporary files, pick one and diff the remainder with it?


Context:

I have to check the output of a certain command on multiple servers and see if they all agree. For the moment, just reporting if any differences are found seems good, but if possible, I'd like to be able to say: X% servers agree with each other, Y% with each other; or that server Z is the odd one.

I have a four-way multi-master LDAP setup, and I want to verify that the ContextCSN values for all four agree with each other.

So now I do:

#! /bin/bash

for i in {1..4}.ldap 
do 
    ldapsearch -x -LLL -H ldap://$i -s base -b dc=example,dc=com contextCSN > $i.csn; 
done
set -e 
for i in {2..4}
do
    diff -q 1.csn $i.csn
done

And check the error code of the script. Are there better tools for this?

Any tools that can be used on Ubuntu 14.04 welcome.

Best Answer

The tool to do this is Diffuse. It is also generally available from repos (at least in Debian and Arch, where I checked). It works as you would expect it to:

  diffuse file1 file2 file3 file4

and so on.