0

I was using this command find . -type f -exec grep -Hn 'TEXT' {} \; in terminal to find all files where TEXT is in file, but right now I want to find all the files in current directory where TEXT isn't in the file.

  • 1
    possible duplicate of [Using grep to find files that don't contain a given string pattern](http://stackoverflow.com/questions/1748129/using-grep-to-find-files-that-dont-contain-a-given-string-pattern) and [Find files that does not contain a string](http://stackoverflow.com/questions/14809800/find-files-that-does-not-contain-a-string) – Abecee Aug 21 '15 at 22:18
  • Yes, it's a dublicate. Couldn't find this link before. Thanks – user2285522 Aug 21 '15 at 22:34

1 Answers1

0

All POSIX-compliant grep implementations should have -v option:

-v
Select lines not matching any of the specified patterns. If the -v
option is not specified, selected lines shall be those that match any
of the specified patterns.

So command to list files that do not contain TEXT should be:

$ find . -type f -exec grep -lv 'TEXT' {} \;
Arkadiusz Drabczyk
  • 11,227
  • 2
  • 25
  • 38