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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help writing a script

Status
Not open for further replies.

13111972

Programmer
Jul 21, 2003
1
US
Hi,
I need to write a script where in -
- do a find for a particular type of files (eg. find . -name *.jsp -print)
- grep on each of the file (which are in different directories )to find if a string exists.
- if it does not exists , email me with the filename.

Any help will be appreciated.

 
Something like this perhaps
Code:
files=`find . -name *.jsp -print`
for i in $files; do
  grep -q "string" $i
  if [ $? -ne 0 ]; then
    echo $i | mail -s Subject user@host
  fi
done
Change the search string and the mail parameters to suit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top