Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List file names where certain keywords are missing. 1

Status
Not open for further replies.

gsgb1

Programmer
Jul 31, 2004
21
CA
Hello,
I have over 200 .txt and .ksh files in a directory having keywords like Revision, Author, Date etc.
Some of the files do not have these keywords in them, and some have 2 out of 3.
I want to identify files that are missing keywords in them.
I could do following to find where its existing, but I want the other way, Files not having keywords.
find . -exec grep -q 'Revision' '{}' \; -print

Any help?

Thanks.
 
Use grep -E -c and filter for not having :3:
find . | xargs grep -E -c 'Revision|Author|Date' | grep -v ':3'


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try
Code:
for file in *.txt *ksh
do
  if ! egrep -i "Revision|Author|Date" $file > /dev/null
  then
    echo $file
  fi
done
OK it's not pretty but it works

Columb Healy
Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it.
 
Oops - I didn't read the question properly - PHV has, as ever, come up with an elegant solution

Columb Healy
Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it.
 
Thanks a lot PHV! It works like a charm.:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top