如果在测试文件中找到一个字符串,如何在dos中使find命令失败?

时间:2016-03-11 09:42:30

标签: batch-file find dos

我必须在文本文件中搜索字符串“Failed”,并希望“find”命令失败或者如果找到字符串则返回失败。

1 个答案:

答案 0 :(得分:1)

findstr /c:"Failed" filename.txt && Echo Failed found || Echo Failed not found

findstr /c:"Failed" filename.txt 
If Errorlevel 1 echo Failed not found or file couldn't be read

请参阅findstr /?if /?

Findstr 0 = found,1 = not found,2 = file not not read。