Is there an easy way using grep (or combine with other standard command line tools) to get a list of all files which contain one pattern yet don't have a second pattern?
In my specific case I want a list of all files that contain the pattern:
override.*commitProperties
yet don't contain:
super.commitProperties
I'm on Windows but use cygwin extensively. I know how to either find all files with the first pattern OR all patterns without the second, but I'm not sure how to combine those queries.
I'd prefer answers that are generic, as I have a feeling plenty of other people could find this type of query useful. It's easy enough for me to take a generic solution and plug in my values. I just included my specific instance to make the explanation easier.
grep -rl "override.*commitProperties" . | xargs grep -L "super.commitProperties"
-l
prints the files with a match
-L
prints the files without a match
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With