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
Windows 'findstr' command: Exclude results containing particular string
提问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 -v
in Windows?
在 Linux 中,这样做的方法是添加| grep -v str2
(grep str1 *
当然)。-v
在 Windows 中是否有等效的标志?
回答by ta.speot.is
Is there an equivalent flag to
-v
in Windows?
-v
在 Windows 中是否有等效的标志?
The equivalent to -v
is /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\\"