findstr for multiple searches?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
billbob
Posts: 2
Joined: 26 Mar 2009 09:23

findstr for multiple searches?

#1 Post by billbob » 06 Apr 2009 14:07

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

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 06 Apr 2009 15:01

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

Post Reply