I need to output the sum of a grep results for a certain time, for now i hard coded the time grep but any help will be very much appreciated, my problem is i cant output the results on the script.
If i use this line, it will give me an output of 1:
cat *.log | egrep '2011-07-01 (04:[0][0-9]:[0-5][1-9]|04:10:00)' * | grep -ach '0110 478655 .. 51' | awk '{SUM += $1} END { print SUM }'
and this line would give me an output of 0 :
cat *.log | egrep '2011-07-01 (04:[1][0-4]:[0-5][1-9]|04:15:00)' * | grep -ach '0110 478655 .. 51' | awk '{SUM += $1} END { print SUM }'
this code needs alot of improvements :
while read line
do
cd $DIR
ta1=`cat *.log | egrep '2011-07-01 (04:[0][0-9]:[0-5][1-9]|04:10:00)' * | grep -ach '0110 478655 .. 51' | awk '{SUM += $1} END { print SUM }'`
ta2=`cat *.log | egrep '2011-07-01 (04:[1][0-4]:[0-5][1-9]|04:15:00)' * | grep -ach '0110 478655 .. 51' | awk '{SUM += $1} END { print SUM }'`
ta=$((ta1 + ta2))
echo -e "Results = $ta "
done
i wanted to add the results and put it on a while do statement, also i needed two grepping so i can sum up all the instances for a 15min cycle., any idea how to do a single grep statement instead?
read line? What is the input to this loop? You don't use the$linevariable anywhere, so I can't figure out what the purpose of the loop is supposed to be. – Caleb Jul 2 '11 at 10:05awkis getting as input. – Gilles Jul 2 '11 at 10:18