Counting a list of 2 numbers from a file, using awk (apache .bytes files)


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » Apache Related Information

Counting a list of 2 numbers from a file, using awk (apache .bytes files)Last Modified: Mar 12, 2015, 11:16 pm
If you want to quickly add up the .bytes files, so you can compare the daily total with webalizer, awk makes this very easy.   The format of the .bytes logs are like this:

6716 681
2408 355
2408 355
338 408
2408 490
2408 390
6709 678
2408 483

where the downloaded bytes for a request is on the left, and the uploaded bytes on the right.

Using awk, you can add up these 2 columns, and display the totals for each column.

cd /var/log/httpd/domains
awk '{d+=$1; u+=$2} END {print d " " u}' dmoain.com.bytes

which will output the downloaded bytes on the left, and the uploaded bytes on the right.

2003 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST