awk '{print $1}' apache.log |sort -n | uniq -c |sort -nr | head
- Get the IPs from first field of apache.log
- Sort the IPs to process it further
- Get the count of each IP
- Sort the IPs based on count
Using regular expression:
grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" apache.log |sort -n| uniq -c | sort -nr | head