thanks for the reply.
What I basically need is to count how many times each error string occurs in the last 20 lines of my log file and based then on the size of this number execute different functions.
This could be done by creating a grep statement and variable for every error string, but there is a chance that more error string may be added using a loop would simplify the script
your proposal will accumulate the number of times the errors occur?
cheers
I could also have written the code better
Code:
error1="it overloaded"
error2="the service died"
error3="It lost to the overlord"
strings=" $error1 $error2 $error3"
for p in $strings ; do
count=` tail /my/log/file -n 20 | grep -ic $p `
echo "testing for $p and found it $count times" >> testlog.file
done