DIFF utility works for 2 files. How to compare mor

2019-03-08 06:36发布

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!

5条回答
爷的心禁止访问
2楼-- · 2019-03-08 07:15

diff has built-in option --from-file and --to-file, which compares one operand to all others.

查看更多
Rolldiameter
3楼-- · 2019-03-08 07:16

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.

查看更多
家丑人穷心不美
4楼-- · 2019-03-08 07:18

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.

查看更多
男人必须洒脱
5楼-- · 2019-03-08 07:27

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

查看更多
狗以群分
6楼-- · 2019-03-08 07:34

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

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

查看更多
登录 后发表回答