Unique Ip address parser

Dean sent me the following to parse the logs and see how many unique ip address's I was getting on a monthly basis.

grep 'Nov/2004' uk*.log | awk '{ print $1 }' | sort | uniq | wc

I wrote the following in Perl which does the same thing but I think I prefer Deans

perl -ne '/^(.*?)\s/; $a{$1}++;} END{for (keys %a){$c++;print "$_ == $a{$_}\n"} print "$c\n";' ukl*ss.log

maybe we could

perl -ane '$a{$F[0]}++};END{for (keys %a){$c++;print "$_ == $a{$_}\n"} print "$c\n";' ukl*ss.log

or maybe even

perl -ane '$a{$F[0]}++} END{for(keys %a){$c++;} print "$c\n";' ukl*ss.log


Or we could just

perl -ane '$a{$F[0]}++;END{print keys(%a)."\n";}' ukl*ss.log

bollicks to this. I am also sure there is some clever one liner in Perl to do this but I hardly ever use them so I will leave it to the reader to beat it ;)

Add to delicious Digg This Add to My Yahoo! Add to Google Add to StumbleUpon
| | Comments (0) | TrackBacks (0)

0 TrackBacks

Listed below are links to blogs that reference this entry: Unique Ip address parser.

TrackBack URL for this entry: http://www.hjackson.org/mt/mt-tb.fcgi/125

Leave a comment

About this Entry

This page contains a single entry by Harry published on November 20, 2004 8:53 PM.

Who's searching on what was the previous entry in this blog.

Do not cast your pearls in front of swine is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01