If file contains string do..else do..end

Hi,

I have a script that runs a sql and outputs it in a temp file. That file is emailed to a distribution group hourly. How can I modify it to email only if a string is present in the file?

$ORACLE_HOME/bin/sqlplus -s '/as sysdba' @$SCRPTDIR/example-01.sql $OUTFILE
/bin/mail -s "$1 example subject in email  `date` " admin@example.com < $OUTFILE
exit

The last line is email 'output file' to admins and I want to change it to email output file to admins IF it contains the string 'example' in it.

---------- Post updated at 12:14 PM ---------- Previous update was at 11:34 AM ----------

Okay I figured it out...

if grep -iFq "string" $file_name
       then /bin/mail -s "subject in email" admin@example.com < $file_name
fi

Sometimes silence is not reliability, so you might want it to send unconditionally, once a day, just to show it is running. You can set a marker file when you send and if it is a day old, send an "I am alive" message. Or, send a summary at midnight of all the emails for the day.