[Gllug] Sum trouble

Martin A. Brooks martin at clues.ltd.uk
Tue Apr 8 09:25:06 UTC 2003


At 10:12 08/04/2003 +0100, you wrote:
>Good morning all
>
>I am trying to calculate the total sum of bytes listed in the apache 
>access_log.
>I have retrieved the particular column which gives me a list of byte 
>values thus:
>cut -f10 -d" " access_log
>I can't seem to find any text type utility that will sum these values.
>What would be the usual procedure to achieve this?

perl -e '$total=0;while (<>){s/.*HTTP//; @tmp=split/ /; 
$total+=$tmp[2]}print "$total\n"' < access_log

This won't _always_ work, but I'll let you work out why :)

Regards

Martin A. Brooks, Clues Ltd
http://www.clues.ltd.uk/ 


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list