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
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
Give this a shot, should work for you.
Wrap both within quotes and separate with a space. Note, you also have to escape the . in both of them.
If you need to include phrases (Space separated words) you can do it:
Or if you are getting some unwanted rows, you can exclude them using the
/v
parameter too:(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.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.