Hey,
I have a file with following data..
and I want to get the summation of 10th column. And this happens in every 10 seconds for a minute max.
242001 A mqsitst 794864 1249516 0 60 20 293050400 77016 * 02:05:33 - 0:04 DataFlowEngine EAITIBR2_BROKER 384403e1-1001-0000-0080-cc759314a02e IDS_CCASS 0
242001 A mqsitst 978998 1249516 0 60 20 24284a400 56092 * 02:05:33 - 0:03 DataFlowEngine EAITIBR2_BROKER 9fa202e1-1001-0000-0080-cc759314a02e 21CD1 0
242001 A mqsitst 1040482 1134684 0 60 20 13d86400 78684 * 02:05:35 - 0:04 DataFlowEngine EAIDQBR2_BROKER 6f8aa7d6-1001-0000-0080-be57c7f1134d WAMS1 0
The BOLD faced has to be added and its in the 10th column.
What should i do to make it easily done ?
Thanks
this will add up the 10th column i didn't understand for what you mentioned "And this happens in every 10 seconds for a minute max"
awk '{sum += $10}END{print sum}' filename
I mean to say by that, that the script/command will execute for a minute and sleep would be of 10 seconds. (I minute = 60 seconds ; i.e. 6 times script will run)
In that timespan, i would like to keep the 6 summations togather and then would add them finally.
in that case you have to save the summation into some intermediate file and add them up at the end of min
Yes..I did that.
Its fine and working.
Thanks:b:
By the way...following is the script. Its running while TRUE and sleep is 10 seconds. It'll work but is Cntrl+C interrupt only solution to stop it? OR can I run while loop for just 1 minute.
while true
do
# echo "********To stop it, press the Interrupt key sequence. Cntrl+C **********"
ps -elf | grep DataFlow > InputFile
awk '{sum += $10}END{print sum}' InputFile >> SumFile
echo >> SumFile
sleep 10
done
keep some counter inside while loop so that when that reach 10 get out of the loop
while [ $count -eq 10 ]
...
...