Piping to findstr's input

廉价感情. 提交于 2019-12-03 05:20:27

I think you're confusing a little how findstr works. It gets input (to find things in – not the things to look for) either as a file name (pattern) or from stdin, but the things you're looking for are always given on the command line as an argument to findstr.

findstr foo xyz.txt

finds the string foo in the file xyz.txt.

type meh.txt | findstr x

finds the string x in the output of the previous command (in this case the contents of the file meh.txt – a nice waste of the type command, much akin to common misuse of cat).

Since you're after the counts instead of the actual lines the macro names appear in, I'd suggest a different approach. This assumes that your file containing the macros lists them one per line:

for /f "delims=" %x in (macros.txt) do @(echo %x: & find /c "%x" *.ss)

The for loop iterates over the contents of your file, line-wise. It then proceeds to print the name you're searching for and executing find /c which actually counts matching lines.

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