管道的“FIND:参数格式不正确”和“FINDSTR:写入错误”

jww*_*jww 9 windows command-line find cmd.exe

我正在尝试编写一个 Windowscmd.exe脚本来计算aes从命令行编译程序后出现的次数。它只是一个审计/质量保证脚本,以确保我们得到我们所期望的。

当我在findstr没有管道的情况下使用时,它似乎工作正常:

cryptopp-5.6.3>dumpbin /disasm Win32/cryptlib/Debug/rijndael.obj | findstr aes
  000000C1: 66 0F 3A DF C0 00  aeskeygenassist xmm0,xmm0,0
  00000206: 66 0F 3A DF C0 00  aeskeygenassist xmm0,xmm0,0
  00000345: 66 0F 38 DB 04 81  aesimc      xmm0,xmmword ptr [ecx+eax*4]
  00000366: 66 0F 38 DB 04 81  aesimc      xmm0,xmmword ptr [ecx+eax*4]
  0000039F: 66 0F 38 DB 04 81  aesimc      xmm0,xmmword ptr [ecx+eax*4]
  00000078: 66 0F 38 DC C8     aesenc      xmm1,xmm0
  000000AB: 66 0F 38 DC C8     aesenc      xmm1,xmm0
  ...
Run Code Online (Sandbox Code Playgroud)

一旦我通过管道将结果find /c用于计算出现次数,事情就会爆炸。不仅没有find按预期工作,它还设法打破了正在进行的findstr命令。

cryptopp-5.6.3>dumpbin /disasm Win32/cryptlib/Debug/rijndael.obj | findstr aes | find /c aes
FIND: Parameter format not correct
FINDSTR: Write error
Run Code Online (Sandbox Code Playgroud)

根据find /?

If a path is not specified, FIND searches the text typed at the prompt
or piped from another command.
Run Code Online (Sandbox Code Playgroud)

如何将 的输出通过管道findstr传输到 的输入find

小智 18

我能够直接用这个语法做我需要做的事情:

find.exe """Find This""" *.log
Run Code Online (Sandbox Code Playgroud)

使用三重双引号,我认为其中 2 个被 POSH 消耗,留下单引号供 FIND 查看..这对我在 Server 2012 R2 上工作得很好..

  • 其次,在 Win 10 上使用 vanilla powershell 可以/需要这样做,我在那里遇到了同样的问题。 (4认同)
  • 通过在搜索字符串之前添加一个 `"` 并在末尾添加另一个,已经令人满意地回答了这个问题。如果这对您不起作用,则表明您有不同的情况。事实上,您正在谈论“POSH ”,问题中没有提到,支持这一点。如果你认为你的问题(无论是什么)适用于其他人,你应该[提出一个新问题](/questions/ask),描述你的情况,然后发布你自己的答案。(在系统让你回答你自己的问题之前,你可能会受到短暂的延迟。) (2认同)
  • 这个答案是正确的。我在 ConEmu 中使用 power shell,需要使用三重引号。请回复您的反对票。 (2认同)
  • 我认为“POSH”是指 Powershell。我以前从未见过这个词。确认这对我有用。太蠢了,竟然需要这个! (2认同)

wee*_*eek 6

在 的参数上使用引号find /c "foo"