I have a rather simple routine that I would like to fine tune. I am having scripters block if that exists. Trying to tally up that amount of subnets after I performed an awk and uniq from zipped apache logs. For instance, on a solaris 10 system:
This does work
gunzip -c access_log1.200834.gz | awk '{print $1}' | uniq -c | sort -nr > log_tally
log_tally would consist of something like:
2 164.156.43.3
1 10.1.1.3
2 10.1.1.1
756 192.168.1.4
328 192.168.1.4
10 164.156.43.3
2 164.156.43.3
1 10.1.1.3
2 10.1.1.1
1 10.1.1.3
3 10.1.1.1
I would like to consolidate and add the duplicate sunbets so that I can have a top 10 or 20 subnet listing. Not mention sort it in reverse order.
I found this on this forum but I need more sophistication:
awk -F" " '{x +=$1} END {print "SUM: "x}' log_tally
As you can imagine, this will take me a while as I would have to do this for every file with its respective subnet. YUCK.
How would I combine these two routines and give me sums for each deduplicated subnet in reverse order?
Any help would be greatly appreciated.