【问题标题】:Windows 'findstr' command: Exclude results containing particular stringWindows 'findstr' 命令:排除包含特定字符串的结果
【发布时间】:2014-05-07 07:15:37
【问题描述】:

对于命令findstr str1 *.*,我想添加一些内容,以排除包含字符串str2 的结果。

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

【问题讨论】:

  • 我在命令窗口中输入了findstr /?,看到/V Prints only lines that do not contain a match.
  • 谢谢。您可以将其添加为答案。

标签: windows command-line findstr


【解决方案1】:

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

-v 等价于/V

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

...

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 哇!我刚刚发现你需要双反斜杠,".git\" 不起作用。唯一的缺点是,文件名不再突出显示 :( 我现在用 findstr /S "needle" * | findstr /V "..." 替换了 wcgrep
    猜你喜欢
    • 1970-01-01
    • 2014-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多