简体   繁体   English

比较两个txt文件并在txt文件中逐行打印差异

[英]Compare two txt files and print the difference line by line in txt file

I have two tab-delimited .txt files, and I want to compare them to each other. 我有两个制表符分隔的.txt文件,我想将它们相互比较。 The end goal is to print the difference in a another .txt file, which will have only the lines where the different data in column occurs. 最终目标是将差异打印在另一个.txt文件中,该文件将仅包含发生列中不同数据的行。 Is it possible to do this with some script in Winodws? 是否可以使用Winodws中的某些脚本来执行此操作?

There is no need to write a script for this manually, although it would be relatively easy to do in eg Python. 尽管例如使用Python相对容易,但无需为此手动编写脚本。 You can install DiffUtils for Windows to get Linux style diff tools. 您可以安装WindowsDiffUtils以获得Linux风格的差异工具。 You can then say (in a shell): 然后,您可以说(在shell中):

diff file1.txt file2.txt

WinMerge could possibly work for you. WinMerge可能会为您工作。 It has a command line interface, if you're looking to automate it. 如果您要使其自动化,则它具有命令行界面。 You can check the manual at http://manual.winmerge.org/Command_line.html . 您可以在http://manual.winmerge.org/Command_line.html上查看手册。 Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM