如何删除Windows中另一个文本文件中存在的文本文件中的所有行?

时间:2016-03-02 11:58:41

标签: windows batch-file cmd

我有两个文件:content.txtremove.txt。我想运行.cmd脚本,删除content.txtremove.txt的所有行。结果应该转到result.txt

例如:

content.txt

abc
1234
hello
qwerty

remove.txt

abc
hello
def

result.txt

1234
qwerty

这个问题是相同的,但是使用Perl:Removing lines in one file that are present in another file。我只能使用标准的Windows工具。

1 个答案:

答案 0 :(得分:2)

findstr /L /v /X /g:remove.txt content.txt>result.txt

/ X表示“完全匹配线”

?L表示“字面意思 - 不是正则表达式”

/ v表示“不匹配”

/ g:filename是用作字符串 - (排除)-source

的文件名

/我会不区分大小写。