If you're into processing text files like this, you'll probably want to invest some time in awk.
Here's a simple example. There may well be better ways to do what I've done, I am no awk expert!
Code:
>cat awk.cmds
BEGIN {
print "My report..."
}
#
# No test here, this action happens for every line
#
{
iplist[$1] += $10;
}
#
# Numeric check on field 10,
# Record bytes uploaded
#
($10+0 == $10) {
TotalBytes += $10;
printf ("IP: %-16s Bytes: %-10d\n", $1, $10);
}
#
# Test for -, meaning no bytes uploaded
#
$10 == "-" {
FailedRequests++;
}
#
# This happens at the end of the run
#
END {
printf ("Total bytes processed: %d\n", TotalBytes);
printf ("Total failed requests: %d\n", FailedRequests);
printf ("\nIP Summary List Follows:\n");
for ( i in iplist )
{
printf ("IP: %-16s TotalBytes: %-10d\n", i, iplist[i]);
}
}
>awk -f awk.cmds access.log.*
....
.... output here... run it and see....