Windows 'findstr' 命令:排除包含特定字符串的结果

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23511172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:33:46  来源:igfitidea点击:

Windows 'findstr' command: Exclude results containing particular string

windowscommand-linefindstr

提问by Subway

To the command findstr str1 *.*I want to add something that will exclude the results which contain the string str2.

在命令中,findstr str1 *.*我想添加一些内容来排除包含字符串的结果str2

In Linux the way of doing it is to add | grep -v str2(to grep str1 *of course). Is there an equivalent flag to -vin Windows?

在 Linux 中,这样做的方法是添加| grep -v str2grep str1 *当然)。-v在 Windows 中是否有等效的标志?

回答by ta.speot.is

Is there an equivalent flag to -vin Windows?

-v在 Windows 中是否有等效的标志?

The equivalent to -vis /V.

相当于-v/V

C:\Users\Todd>findstr /?
Searches for strings in files.

...

/V         Prints only lines that do not contain a match.

回答by 1lOtzM291W

use /V, for example: findstr "hello world" *.cpp | findstr /V ".git\\"

使用/V,例如:findstr "hello world" *.cpp | findstr /V ".git\\"