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