Old.txt
包含
apple
orange
banana
和
New.txt
包含apple
orange
banana
grape
lemon
我可以访问添加到
New.txt
的新内容使用 grep
命令。grep -Fxvf Old.txt New.txt > difference.txt
现在,
difference.txt
包含grape
lemon
在 Windows 中,我尝试过
findstr /rvc:Old.txt New.txt > difference.txt
找到差异,但它附加了
Old.txt
的内容也。如何在 Windows 中编写等效命令?
最佳答案
您可以使用 DOS
findstr
带有以下标志:-
/v : Prints only lines that do not contain a match.
/g: file : Gets search strings from the specified file.
该命令将类似于:-
C:\Users\dude\Desktop>findstr /v /g:Old.txt New.txt >difference.txt
现在使用
type
检查文件输出命令;相当于 cat
在 Linux
, 我们看 :-C:\Users\dude\Desktop>type difference.txt
grape
lemon
关于cmd - 适用于 Windows 的 Grep,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38700487/