需要在Apache日志文件中对IP进行排序 [英] Need to sort ips in Apache log file

查看:61
本文介绍了需要在Apache日志文件中对IP进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Apache访问日志.我想要一个IP列表,按IP进行的访问次数(计数)排序,而不是计数.只是IP地址按访问次数排序.

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

这给出了类似的输出:

10000 66.249.79.18

10000 66.249.79.18

10000 是计数值.我只需要IP,不需要计数.那么修改后的命令是什么?谢谢!

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

推荐答案

尝试删除 uniq 命令的 -c .这将消除计数的第一列.

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

完整命令

cat access_log | awk '{print $1}' | sort -n | uniq | sort -nr | head -200

这篇关于需要在Apache日志文件中对IP进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆