Script to find string & email

Hi

I have a query that some of you may be able to help me with if poss? I'd appreciate it very much.

I've got a few log files, that I would like to search for a string. When the string is found, i'd then like to email out the line/sting.

If not found, i'd like to email out 'no found' etc.

so i've been wrecking my brains reading books etc. (i'm a complete beginner!)

anyhow, can anyone help/expand on this:

cd /export/home # so 1st command moves to where log files are
awk '/string_searching_for_here/' log_file_names* |mailx -s "subject_of_email" toemailaddress@test.com

this sort of works. I'm not sure how to then send an email if nothing is found.

I take it i should use the 'if' etc?

thanks

grep "pattern" log_file_names* > /dev/null &&  grep "pattern" log_file_names*| mailx -s "subject_of_email" toemailaddress@test.com || (echo "Nothing Found" | mailx -s "subject_of_email" toemailaddress@test.com)

thank worked a treat! thank you very much!!