views:

665

answers:

4

So the utility Diff works just like I want for 2 files, but I have a project that requires comparisons with more than 2 files at a time, maybe up to 10 at a time. This requires having all those files side by side to each other as well. My research has not really turned up anything, vimdiff seems to be the best so far with the ability to compare 4 at a time.

My question: Is there any utility to compare more than 2 files at a time, or a way to hack diff/vimdiff so it can do multiple comparisons? The files I will be comparing are relatively short so it should not be too slow.

Thanks in advance!

+2  A: 

Checkout "Beyond Compare": http://www.scootersoftware.com/

It lets you compare entire directories of files, and it looks like it runs on Linux too.

Scott Anderson
diff -r also compares entire directories of files, but it only ever compares the files from one driectory against the files from the other directory
reinierpost
+2  A: 

Vim can already do this:

vim -d file1 file2 file3

But you're normally limited to 4 files. You can change that by modifying a single line in Vim's source, however. The constant DB_COUNT defines the maximum number of diffed files, and it's defined towards the top of diff.c in versions 6.x and earlier, or about two thirds of the way down structs.h in versions 7.0 and up.

Noah Medling
vimdiff or vim -d can only do 4 files at a time at least on my computer. anyone know how to bypass this?
Javed Ahamed
I didn't notice the mention of that in the question. Updated to include instructions on changing Vim's limit.
Noah Medling
Hey, do you know how to actually get to structs.h or diff.c? I cant find the vim source code on Win or Linux.
Javed Ahamed
Vim's source is available here: http://www.vim.org/sources.php
Noah Medling
+2  A: 

if your running multiple diff's based off one file you could probably try writing a script that has a for loop to run through each directory and run the diff. Although it wouldn't be side by side you could at least compare them quickly. hope that helped.

Benjamin Neil
yeah but if i was comparing for example 3 files, i would want them to all diff against each of the other 2 files, since diff does that rearranging to see where they match up.
Javed Ahamed
i found this command that might help with your script, its called diff3 and supposedly its a utility to compare three files. http://linux.about.com/library/cmd/blcmdl1_diff3.htmthe windows version can be found herehttp://gnuwin32.sourceforge.net/packages/diffutils.htm
Benjamin Neil
+3  A: 

Displaying 10 files side-by-side and highlighting differences can be easily done with Diffuse. Simply specify all files on the command line like this:

diffuse 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt 10.txt

Wow this is awesome! Thanks for the response even late, I still needed the help.
Javed Ahamed
What is this sort of comparison called?
leeand00