如何在cmd中找到两个文件之间的区别

时间:2019-11-01 11:30:48

标签: windows file text cmd compare

我正在尝试比较两个文件,并在另一个文本文件中获得输出。到目前为止,我已经检查并仅找到针对Unix或其他操作系统的解决方案,但我正在寻找Windows 10解决方案。

这些是我到目前为止所看到的:

Find the difference between two files

How to find difference between two text files in different directories in ubuntu os through command-line

https://www.howtogeek.com/206123/how-to-use-fc-file-compare-from-the-windows-command-prompt/

https://www.softwaretestinghelp.com/compare-two-files-unix/

https://superuser.com/questions/805522/compare-two-files-and-output-the-differences

这种工作,但不完全是:

fc D:\Logs\Allchannels.txt D:\Logs\check.txt > D:\Logs\missing.txt

这给出的输出是两个文件的内容列表,然后用户将不得不手动查看文件并自己找出差异。

我想要的是一个仅显示两者之间缺少内容的文本文件。

两个fil中的内容示例:

  

文件1:

     
    
        
  • 购物车

  •     
  • Box

  •     
  • 金钱

  •     
  
     

文件2:

     
    
        
  • 购物车

  •     
  • 金钱

  •     
  

因此第3个文件的输出应为Box,因为这是缺少的值。

1 个答案:

答案 0 :(得分:0)

您可以使用Git BASH https://gitforwindows.org/
并使用以下命令执行与您的操作类似的操作:

git diff path/to/file-1 path/to/file-2 > diff.txt