count a unique field in text file

i was just perusing my access_log, and fancied counting the number of times unique ip addresses had access my site. just because.

i started by using cat to see the access_log

cut the first field using cut -f1 -d’ ‘

sorted that list of ip’s

uniq’d it and used -c to add a count

then sorted that.

[code]cat access_log | cut -f1 -d’ ‘ | sort | uniq -c | sort[/code]

Leave a Reply

Your email address will not be published. Required fields are marked *