0

Adding bytes in log file to get the sum

Here’s a simple one liner that will get you the sum of all of the bytes recorded in your access log (assuming that you are in the /var/www/vhosts/yourdomain/statistics/logs/ directory via SSH):

for i in `cat file_name | awk '{print $10}'`; do sum=$((i+=sum)); done; echo $sum

Replace file_name with the name of your access log.

Note: the above command will work on a CentOS5 server. If you are using any other Linux distro, make sure that the awk command is referencing the correct column.

Copyright © 2010 — | Site design by Trevor Fitzgerald