This code below allows me to find the word “error” in all my files using command-line (CMD).
find /c "error" C:\MyFiles\*.txt
But I want it to look for the word “error” and “warning” at the same time.
So I want to put these 2 lines in as 1 line of command.
find /c "error" C:\MyFiles\*.txt
find /c "warning" C:\MyFiles\*.txt
I do not want to see 2 result sets.
This should work (
FINDSTRsplits the search string at spaces, so it looks for either word).As should this equivalent search:
However, there is this bug: Why doesn't this FINDSTR example with multiple literal search strings find a match?. I’m not sure if the above searches would meet the criteria that specify when the bug might affect the results. (I’m not sure if there enough overlap between the search strings.) But better to be safe than sorry.
You can eliminate the possibility of the bug by either making the search case insensitive (not sure if that meets your requirements or not):
or you can convert your search strings into regular expressions. This is trivial to implement in your case since there are no regex meta-characters that need escaping in your search strings.