简体   繁体   English

比较 2 个文本文件并显示它们之间的差异(PowerShell 或 CMD)

[英]Compare 2 text files and display the difference between them (PowerShell or CMD)

I have 2 text files text1.txt contains:我有 2 个文本文件text1.txt包含:

fc1/1 storage
fc1/5 switch
fc1/7 replication

text2.txt contains: text2.txt包含:

fc1/1 storage
fc1/5 nas
fc1/7 replication

I want a script that compares the 2 text files and generate text found on text2.txt but not on text1.txt in a text file named difference.txt我想要一个脚本来比较 2 个文本文件并生成在text2.txt但不在text1.txt上的文本文件中的名为difference.txt的文本

difference.txt contains difference.txt .txt包含

fc1/5 nas

any ideas?有任何想法吗?

Maybe ...也许 ...

findstr /v /g:text1.txt text2.txt  > difference.txt

Search text2.txt for lines not matching ( /v ) lines in text1.txt搜索text2.txt不匹配(线/v中)线text1.txt

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

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