SHELL 分析日志
时间:2014-07-11 00:53 来源:linux.it.net.cn 作者:IT网
列出当天访问次数最多的IP
命令:cut -d- -f 1 /usr/local/apache2/logs/access_log |uniq -c | sort -rn | head -20
原理:
cut
-d, --delimiter=DELIM
use DELIM instead of TAB for field delimiter
表示用-分割,然后-f 1
-f, --fields=LIST
select only these fields; also print any line that contains no
delimiter character, unless the -s option is specified
表示打印第一部分,就是ip
uniq 是将重复行去掉, -c表示前面前面加上数目,
sort -rn 就是按照数字从大到小排序,
head -20取前面20行
最后打印的结果大概是这样:
217 192.114.71.13
116 124.90.132.65
108 192.114.71.13
102 194.19.140.96
101 217.70.34.173
100 219.235.240.36
以下是其他一些分析日志的shell用法:
(责任编辑:IT)
列出当天访问次数最多的IP
命令:cut -d- -f 1 /usr/local/apache2/logs/access_log |uniq -c | sort -rn | head -20
以下是其他一些分析日志的shell用法: (责任编辑:IT) |