Page 1 of 1

findstr for multiple searches?

Posted: 06 Apr 2009 14:07
by billbob
How do I do a findstr if I'm looking for more than 1 string?

This is what I have...but it's not looking for either or, it's only finding one?

findstr /I d10-p.sc.xxx.com cats5c.sc.xxx.com
if not %errorlevel==0%
goto END

Posted: 06 Apr 2009 15:01
by avery_larry
Put the multiple strings to search for inside quotes, separated by spaces. Use the /c option if you want to search for the phrase instead of each individual string:

Code: Select all

findstr /i "string1 string2" "path:\file.txt"

searches for any line that contains string1 OR string2 inside path:\file.txt


Code: Select all

findstr /i /c:"string1 string2" "path:\file.txt"

searches for the exact phrase "string1 string2" (without the quotes) in the file path:\file.txt

Great stuff here:
http://www.ss64.com/nt/findstr.html