~ cat access.log.10 | awk ‘{a[$1]++} END {for(b in a) print b"\t"a[b]}‘ | sort -k2 -r | head -n 10 163.177.71.12 972 101.226.68.137 972 183.195.232.138 971 50.116.27.194 97 14.17.29.86 96 61.135.216.104 94 61.135.216.105 91 61.186.190.41 9 59.39.192.108 9 220.181.51.212 9
显示所有ip:n,(n表示次数)
cat web_737_com.access_log | awk ‘{a[$1]++} END {for(b in a) print b":"a[b]}‘
61.138.100.90:20
157.55.39.125:3
121.42.0.56:2
。。。。
显示10条,没排序
cat web_737_com.access_log | awk ‘{a[$1]++} END {for(b in a) print b":"a[b]}‘ | head -n 10
61.138.100.90:20
157.55.39.125:3
121.42.0.56:2
207.46.13.80:8
123.11.99.148:46
59.172.149.197:12
125.112.245.207:58
123.169.142.98:35
222.128.136.228:10
1.71.34.67:14
原文:http://skinglzw.blog.51cto.com/10729606/1831757