1

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).

Suggestions?

1 Answer 1

2

tl:dr:

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.

-I

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

1
  • Thank you, this does the trick. I had to do a more complicated command, but -L is the magic here.
    – Dan M
    Commented Feb 27, 2016 at 16:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .