Get Inique IP addresses from Apache access.log

The following can be used to fetch the unique records from apache access.log. This example covers IP addresses of the clients but this example can be used to extract other data as well:

cat access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20

It also will work for nginx access logs because visitor’s IP address is also a first field for every row.