How to get unique number of website visitors

Visitors count is probably first number you want to know about your pages. Before you can explorer actual number of visitors you have to prepare your access log files. You may have to filter out search engine robots and the other automatic bots. After that you can explore your first website numbers.

First attempt

Easiest way to get unique visitors is to filter out all unique IP addresses from your log. There is one command line to get all work done:

cat log.txt | cut --delimiter=" " --fields=1 | sort | uniq | wc --lines

You'll get all IP addresses, strip other information from request record, sort them and get only one unique IP per line. At the end wc -l count all lines in output.

IP address problems

Behind one IP address you can find more than one visitor for your page. On the other side some IP addresses can be from some search engine spiders or other bots.