Lets say you wanted to count the number of unique IP addresses hitting your Apache server. It’s very easy to do in a Linux (or compatible) shell. In this tutorial, I’m using Ubuntu server.
First, locate the log file that you want to extract. For example, apache2 log file is located at /var/log/apache2 (depending on your distro). For nginx, the log file is located at /var/log/nginx.
Here I give you the first example on how to extract & count unique IP address in Nginx log file.
Nginx Access Log file
Nginx Error Log file
Next, is the step on how to extract & count unique IP address from Apache log file.
Apache access & error log file
Apache Access Log file
Apache Error Log file
If you have any other step, you can share with me in the comment section. Hope it helps! 🙂