查找命令 windows cmd

Find command windows cmd

I 运行 一条查找文件中字符串实例数的命令:

find /c /i "pass" result.txt

输出为:

---------- RESULT.TXT: 6

如何删除 ---------- RESULT.TXT: 以便我只有号码 6

创建一个输入重定向,而不是将文件名作为参数传递

find /c /i "pass" < result.txt

您可以使用 for /F 循环解析 find 的输出,如下所示:

for /F "tokens=2 delims=:" %L in ('find /c /i "pass" result.txt') do (echo %L)

要在批处理脚本中使用此代码,请将 %L 替换为 %%L