Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Alright. So we have a lighttpd server pumping out the loading of our images.

It logs on a daily basis, and we're considering moving all those images to our S3 account for better load times, but before we can do that i need to get atleast a "feel" for what our transfer will look like.

So right now we have the standard lighttp access log

accesslog.filename = "/var/log/lighttpd/images.access_log" accesslog.format = "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""

so want to dump all the "bytes transferred" from that log file, nice and easy.

cat images.access_log | awk '{print $10}'

which kicks out a output similar to this.


Now -- I've done a bit of googling and maybe i'm forgetting something, is there a command hidden away in linux somewhere that will take all that output, and just add it all together for me? so i can run this command and just have it spit out an absurdly large number every day until i get a baseline of our bandwidth per day?

--- EDIT ---

i Found

IS there anyway to get awk to return the full number, instead of doing what is shown below?

cat images.access_log | awk '{print $10}' | awk '{s+=$1} END {print s}' 
share|improve this question
up vote 3 down vote accepted

Try cat images.access_log | awk '{print $10}' | awk '{s+=$1} END {printf "%.f\n",s}'

share|improve this answer
this did the trick, thanks – GruffTech May 10 '11 at 20:34

You can combine these into one command. If the 10th column has the numbers, then:

awk '{s+=$10} END {printf("%.d\n",s)}' images.access_log 
share|improve this answer
useful as well, thanks. – GruffTech May 10 '11 at 20:34
+1 for killing unnecessary cating and piping. – Kromey May 11 '11 at 0:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.