0
我想在文本文件中搜索一行,如果找到该行则返回true,否则返回false。批量测试一个命令的结果是否为空
这我怎么FINF线,但我不知道如何来测试它:
findstr /r /c:"^Process Status.*no errors, no warnings$" myfile.log
你能不能帮我在这吗?
感谢,
史蒂夫
我想在文本文件中搜索一行,如果找到该行则返回true,否则返回false。批量测试一个命令的结果是否为空
这我怎么FINF线,但我不知道如何来测试它:
findstr /r /c:"^Process Status.*no errors, no warnings$" myfile.log
你能不能帮我在这吗?
感谢,
史蒂夫
findstr /r /c:"^Process Status.*no errors, no warnings$" myfile.log > nul
if errorlevel 1 (
echo The line was not found
) else (
echo The line was found
)
检查的命令集ERRORLEVEL。如果设置,则文本未找到。
太棒了!这正是我需要的,非常感谢你! – user2269756
此问题已在相关帖子中回答:http://stackoverflow.com/questions/7605328/batch-how-to-set-findstr-result-to-a-variable-and-disable-findstr-print -to-conso?rq = 1 –
这个问题的标题非常误导。 – skeept