Last active
March 23, 2024 02:44
-
-
Save adamjarret/3ff8762ddc4344905273cd83431b5179 to your computer and use it in GitHub Desktop.
grep for files that contain "string-a" but not "string-b"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thanks https://unix.stackexchange.com/a/128436 | |
grep -le "string-a" * --null | xargs -0 -n 1 -I {} grep -Le "string-b" "{}" | |
# Simplified version can be used if file paths have no spaces: | |
grep -Le "string-b" $(grep -le "string-a" *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment