如何删除Windows中另一个文本文件中存在的文本文件中的所有行? [英] How do I remove all the lines in a text file that are present in another text file in Windows?

查看:30
本文介绍了如何删除Windows中另一个文本文件中存在的文本文件中的所有行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have two files: content.txt and remove.txt. I would like to run .cmd script that removes all lines from content.txt that are in remove.txt. The result should go to result.txt.

例如:

content.txt

abc
1234
hello
qwerty

remove.txt

abc
hello
def

result.txt

1234
qwerty

这个问题是相同的,但是使用Perl:

This question is the same but using Perl: Removing lines in one file that are present in another file. I can only use standard Windows tools.

推荐答案

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

/X表示精确匹配线"

/X means "match lines exactly"

?L的意思是字面意义-不是正则表达式"

?L means "literally - not regex"

/v表示不匹配"

/g:文件名是用作字符串-(排除)-源的文件名

/g:filename is filename to use as string-(exclusion)-source

/我会区分大小写.

这篇关于如何删除Windows中另一个文本文件中存在的文本文件中的所有行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆