Skip to content

Instantly share code, notes, and snippets.

@adamjarret
Last active March 23, 2024 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamjarret/3ff8762ddc4344905273cd83431b5179 to your computer and use it in GitHub Desktop.
Save adamjarret/3ff8762ddc4344905273cd83431b5179 to your computer and use it in GitHub Desktop.
grep for files that contain "string-a" but not "string-b"
# 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