Support Center > Knowledgebase > DirectAdmin > Apache Related Information > Counting a list of 2 numbers from a file, using awk (apache .bytes files)
Counting a list of 2 numbers from a file, using awk (apache .bytes files)
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.
Also Read