Reputation: 4929
I am looking for a batch file to search through a txt file and if it finds the word "Failed" then EXIT 1. Any help??
Upvotes: 0
Views: 15679
Reputation: 1235
here is something similar to what Garrett said, but you can run it as a background process while for instance displaying some other info on stdout:
@echo off
@start /wait FIND /C /I "SearchPhrase" path-to-your-file\filename.abc
IF ERRORLEVEL 1 (do-something)
Upvotes: 1
Reputation: 15769
FindStr "Failed" YourFile.Txt >Nul:
If ErrorLevel 1
... then it is NOT found (findstr returns 0 if found
Upvotes: 0
Reputation: 1790
This might get you started...
type file.txt | find "Failed"
If that returns anything, you set the ERRORLEVEL variable to 1.
Hope that helps dude!
Upvotes: 1