Sort unique IP address from Apache log

December 15, 2015 by Linux Guru

Filed under logs

Last modified June 15, 2016

how to sort unique IP address from Apache log

I need to extract only unique IP addresses from my apache log file or Sort unique IP address from Apache log

Use following command for getting unique ip from log file

 $awk ‘{ print $1 } ‘ /var/log/httpd/access_log | sort | uniq -c

OR

$cat /var/log/httpd/access_log |awk ‘{ print $1 } ‘| sort | uniq -c

for compress log file

$zcat /var/log/httpd/access_log.20151123.gz | awk ‘{ print $1 } ‘| sort | uniq -c

Leave a Comment