Html DIFF 实用程序适用于 2 个文件。如何一次比较两个以上的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1075708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DIFF utility works for 2 files. How to compare more than 2 files at a time?
提问by Javed Ahamed
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.
因此,实用程序 Diff 就像我想要的 2 个文件一样工作,但我有一个项目需要一次与 2 个以上的文件进行比较,可能一次最多 10 个。这也需要将所有这些文件并排放置。我的研究并没有真正发现任何东西,vimdiff 似乎是迄今为止最好的,能够一次比较 4 个。
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.
我的问题:是否有任何实用程序可以一次比较 2 个以上的文件,或者有什么方法可以破解 diff/vimdiff 以便进行多重比较?我将要比较的文件相对较短,所以应该不会太慢。
Thanks in advance!
提前致谢!
回答by
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可以轻松地并排显示 10 个文件并突出显示差异。只需像这样在命令行上指定所有文件:
diffuse 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt 10.txt
扩散 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt 10.txt
回答by Noah Medling
Vim can already do this:
Vim 已经可以做到这一点:
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.
但您通常仅限于 4 个文件。但是,您可以通过修改 Vim 源代码中的一行来更改它。该常量DB_COUNT
定义了最大差异文件数,它diff.c
在 6.x 及更早版本中定义为顶部,或structs.h
在 7.0 及更高版本中向下定义约三分之二。
回答by Peacher Wu
diff
has built-in option --from-file
and --to-file
, which compares one operand to all others.
diff
具有内置选项--from-file
and --to-file
,它将一个操作数与所有其他操作数进行比较。
--from-file=FILE1
Compare FILE1 to all operands. FILE1 can be a directory.
--to-file=FILE2
Compare all operands to FILE2. FILE2 can be a directory.
回答by Scott Anderson
Checkout "Beyond Compare": http://www.scootersoftware.com/
结帐“超越比较”:http: //www.scootersoftware.com/
It lets you compare entire directories of files, and it looks like it runs on Linux too.
它可以让您比较整个文件目录,而且它看起来也可以在 Linux 上运行。
回答by Benjamin Neil
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.
如果您基于一个文件运行多个差异,您可能会尝试编写一个具有 for 循环的脚本来运行每个目录并运行差异。虽然它不会并排,但您至少可以快速比较它们。希望有所帮助。