How do I remove all the lines in a text file that are present in another text file in Windows?

纵饮孤独 提交于 2021-01-29 01:40:17

问题


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.

For example:

content.txt

abc
1234
hello
qwerty

remove.txt

abc
hello
def

result.txt

1234
qwerty

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.


回答1:


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

/X means "match lines exactly"

?L means "literally - not regex"

/v means "not -matching"

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

/I would make case-insensitive.



来源:https://stackoverflow.com/questions/35746578/how-do-i-remove-all-the-lines-in-a-text-file-that-are-present-in-another-text-fi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!