search files which doesnot match pattern ?

Hi

I need a command to search files in a directory which does not match with pattern .. Plz send me this

Ex : Test is directory and has some 10 files with different name all are with *.dat extension , need to search files which doesnot contain word "Dummy file".

Thanks

find . -name "*.dat" | xargs grep -v "Dummy file"

Thanks

That will just display all lines in all files that do not contain "Dummy file".

Try this instead:

# list files that *do* contain "Dummy file" and save in a file
grep -l "Dummy file" * > /tmp/matches
# use that file to exclude them from the list of files
ls | grep -xvf /tmp/matches

Use this

find -name "*.dat" | xargs grep -L "Dummy File"

Why reply to a thread that is 10 months old, which has already been answered, and give the wrong answer???

Oh ... I just came across this using Google looking for something. Thought I would post the answer. Maybe, someone else would benefit. Anyways, I dont see why the answer is wrong.

My apologies, I replied in haste... your answer is correct. I misread -L as -l (I didn't know about the -L inverse feature in GNU grep).