This may be a stupid question but even after reading the documentation I'm still not sure how to find all lines in a file that contain either ".cpp" or ".h".
Is there a way to do that?
For example (doesn't work):
findstr /i .cpp,.h // , == OR
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
If you need to include phrases (Space separated words) you can do it:
findstr /i /c:"IBSS" /c:"WDI Version" /c:"Soft Ap"
Or if you are getting some unwanted rows, you can exclude them using the
/v parameter too:
findstr /i /c:Hosted /c:Version /c:Driver | findstr /v /i /c:drivers /c:native
(Tested this on Windows 7 and Windows 10)
How you form the
OR logic depends on what you're looking for and your anticipated future changes, if applicable.
If it's a list of queries that have no whitespace in them, you can just do it like this, quick & dirty:
findstr "thing1 thing2 thing3 thing4 thing5" and if any of those things are present, it will evaluate to true and exit 0.
If what you're looking for does have whitespace, you have to use
findstr's literal search strings with the
/c:"" type of parameter. You can still use this type of parameter if there is no whitespace.
/C:string Uses specified string as a literal search string.
However, you cannot combine literal with quick & dirty. For example, this won't work:
findstr "thing1 thing2" /c:"thing3 thingy"
You'd need to convert the earlier parameters to literal parameters, like so:
findstr /c:"thing1" /c:"thing2" /c:"thing3 thingy"
Because of this, it's a better practice to use the literal option because it will scale better with dynamic scripts. However if it's just a static set of queries that have no whitespace, the quick & dirty way should suffice.