比较一些文本文件的最佳方式

Best way to compare some text files

这是我正在处理的情况的简化版本:

我想找到比较这些文件的最佳方式。我只需要知道哪些文件不同。例如,我需要知道 a.txtFiles2 文件夹中的 a.txt 不同(我不需要知道它们内部有什么不同)。

现在我在 Notepad++ 中加载两者并使用比较功能,但这很痛苦。

我试过 fc,但我得到的是神秘的输出。

Rsync 可用于执行此操作。

 rsync -rvnc —delete delme/ delme2/

这将向您显示 2 个目录中哪些文件不同。

有关我的详细信息,请参阅 http://www.techrepublic.com/blog/linux-and-open-source/how-to-compare-the-content-of-two-or-more-directories-automatically/

干运行 (/l) robocopy:

robocopy C:\files1 C:\files2 /njh /njs /ndl /l

/l    Specifies that files are to be listed only (and not copied, deleted, or time stamped).

您可以为此使用 Robocopy

robocopy c:\Temp\different\folder1 c:\temp\different\folder2 /e /l /ns /njs /njh /ndl /fp /log:c:\temp\whatIsDifferent.txt

     Newer                       c:\Temp\different\folder1\b.txt
     New File                    c:\Temp\different\folder1\d.txt

关键参数是 /L,它允许您 "compare" 而不是实际复制。

来自 Robocopy /?帮助

::
:: Logging Options :
::
                 /L :: List only - don't copy, timestamp or delete any files.