访问前十的URL(可以用来分析网站哪个模块最受欢迎)

awk ‘{print $7}’ www.xxwan.com.log | sort | uniq -c |sort -nr -k 1|head -10

1595483 /games/search_game.php?type=game&k=1?21jhgf
833639 /games/search_game.php?type=game&k=#$csd!
734697 /games/card.php?gid=366
75786 /games/search_game.php?type=game&k=w2qsdw
31686 /games/card.php?gid=518
6367 /bbs/uc_server/index.php?__times__=1
2387 /upimg/a/1479719869638.jpg
2042 /
1673 /upimg/images//1524216154946.jpg
1647 /upimg/images//1486691754833.jpg

 

 

awk统计ip访问量(一条命令)

对下面的1.log 文件进行统计,

要求: 统计出每个IP的访问量有多少? 提示,先awk过滤出ip,然后进行排序,统计重复数。

只用一条命令即可

awk ‘{STAT[$1]++};END{for(A in STAT) print STAT[A], A}’ 1.log|sort -nr|head -10

1.log   的大致格式:

200.104.118.180 – – [27/Jun/2018:10:47:34 +0800] “GET /games/search_game.php?typ
e=game&k=w2qsdw HTTP/1.1” 404 564 “http://www.xxwan.com/games/search_game.php?ty
pe=game&k=w2qsdw” “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTM
L, like Gecko) Chrome/57.0.2987.98 Safari/537.36” –
77.50.62.6 – – [27/Jun/2018:10:47:34 +0800] “GET /games/search_game.php?type=gam
e&k=w2qsdw HTTP/1.1” 404 564 “http://www.xxwan.com/games/search_game.php?type=ga
me&k=w2qsdw” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Mo
zilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 3.5.30729)” –
90.189.159.36 – – [27/Jun/2018:10:47:34 +0800] “GET /games/search_game.php?type=
game&k=w2qsdw HTTP/1.1” 404 564 “http://www.xxwan.com/games/search_game.php?type
=game&k=w2qsdw” “Mozilla/4.0 (compatible; MSIE 6.0; Windows XP 5.1) Lobo/0.98.4”