To find 3 patterns in a file

hy i have a requirement in which my script needs to find 3 patterns in a file and if any pattern is missing it should sent a mail

Patterns


Interval60min_Daily_readings$a.txt
Interval_Daily_readings$a.txt
Daily_readings$a.txt

Basically i want to test for the above Patterns in the file generated by the script .How shall i implement this logic in my script

Below my script

#!/bin/ksh

rm -rf all_rep_files.txt
TZ=`date +%Z`+24 ;a=`date +"%m%d%Y"`
echo $a

for i in 616498114_ReliantES 799530915_ReliantRS  
do
        echo "user odad odd" > ftp.txt
        echo "prompt" >> ftp.txt
        echo "cd $i" >> ftp.txt
        echo "ls -ltr" >> ftp.txt
        echo "bye" >> ftp.txt
        ftp -nv ftp.oncor.com < ftp.txt > ftplog_$i.log
        echo "Completed for $i"
        cat ftplog_$i.log | egrep "Interval_Daily_readings$a|Daily_readings$a|Interval60min_Daily_readings$a" > ftplog_$i.txt
        echo "**********************CONTENTS OF REP $i*****************************" >> all_rep_files.txt
        cat ftplog_$i.txt >> all_rep_files.txt
        rm -rf ftplog_$i.log

########here only i need to test in the file ftplog_$i.txt for those patterns and if not found should mail the pattern#############

If [ `wc -l ftplog_$i.log | cut -d" "  -f1` -lt 3 ]; then
mailx -s "Missing file" blah blah blha
exit 1
else
something
fi

-Devaraj Takhellambam

devtakh's solution tells you if the file has less than three lines. Maybe this is all you need and I have misunderstood the situation, but I would use grep(1) to check for the occurrence each pattern, e.g.

for pattern in pattern0 pattern1 pattern2
do
    grep -q $pattern $file || mail -s "No $pattern in $file" someone@somewhere
done

Note that this will send a separate email for each missing pattern -- I don't know if that's what you want.

N.B. Something similar has been asked before:

but I'm not convinced about the answer there -- it will work as long as all three patterns are on the same line, but maybe that's a good assumption for you.