Linux – How to search for text files that do NOT contain a word


I need to be able to search a directory for all files that do not contain a certain word. My issue with my approaches so far is that they return every line of every file that does not contain the word. I just need a list of files that don't contain it.

Is there a program that does this? I prefer windows, but I also can use linux commands if you have one. I thought about grep -v, but this ends up printing out every lien of every file in a large directory (since most lines do not contain the phrase). I just need the file names (but contents searched).


Best Answer


grep -rIL searchword

According to the Manual:

-R, -r, --recursive

Read all files under each directory, recursively; this is equivalent to the -d recurse option.

-L, --files-without-match

Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The scanning will stop on the first match.


Process a binary file as if it did not contain matching data; this is equivalent to the --binary-files=without-match option.