Need to sort ips in Apache log file

2019-06-13 19:44发布

I have the Apache access logs. I want a list of IPs sorted by number of accesses they have made (count) but not the count number. Just the IP addresses sorted by access counts.

I have this command I've found here:

cat access_log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -200 > output.txt

This gives an output like:

10000 66.249.79.18

10000 is the count number. I need the IP only not the count. What is the modified command then? Thanks!

1条回答
等我变得足够好
2楼-- · 2019-06-13 20:17

Try removing the -c for the uniq command. This will eliminate the first column which is the count.

Full command

cat access_log | awk '{print $1}' | sort -n | uniq | sort -nr | head -200
查看更多
登录 后发表回答