Hi,
I have a script that compares two files(which are updated dynamically by a daemon) and evaluate results from the comparision.
For the first line of comparision from the file1, i will grep some part of the line in file with file1 and set a counter for that particular comparison. So for each and every line there should be a counter variable assigned and set.
So now the first run of script ends... and the next run starts.
For the next run, the script may find some more patterns from file and will grep for that pattern in file1 and set a counter for the new patterns...., above process continues.
Here, I have a problem storing a counter variable for a particular pattern. If script matches the particular pattern on its next run, it should increment the counter assigned for that pattern - else it should leave the counter for that pattern as it is.
This is what i have tried:
#!/bin/bash
file="/home/reddybs/test/failures.log"
file1="/home/reddybs/test/failures.log1"
file3="/home/reddybs/test/pc.chk"
ff=0
while read LINE
do
i=`echo $LINE | awk '{print $4,$5}'`
#echo $i
grep -w "$i" $file1 >>/dev/null
if [ `echo $?` -eq 0 ]
then
echo "matched"
#Please guide me to assign a counter for this particular pattern
ff=`expr $ff + 1`
echo "$ff ,Matched count for $i" >>$file3
else
echo "Yet to implement"
fi
done < $file
Struk in assiging/set a counter variable for the particluar pattern/match/comparision/loop.
Thanks in advance for all your time.....
Cheers,
Sai