The third shell programming

Topic requires log access.log, reads in part, the statistics of the number of visits for each IP
112.111.12.248 - [25 / Sep / 2013 : 16: 08: 31 +0800] formula-x.haotui.com "/ seccode ? .php Update .5593110133088248 = "200" http://formula-x.haotui.com/registerbbs.php "" Mozilla / 4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;) "
61.147.76.51 - [25 / sep / 2013: 16: 08: 31 +0800] xyzdiy.5d6d.com "/attachment.php?aid=4554&k=9ce51e2c376bc861603c7689d97c04a1&t=1334564048&fid=9&sid=zgohwYoLZq2qPW233ZIRsJiUeu22XqE8f49jY9mouRSoE71" 301 " HTTP: //xyzdiy.×××thread-1435- 1-23.html "" Mozilla / 4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; the .NET the CLR 1.1.4322; the .NET the CLR 2.0.50727) "

#!/bin/bash
file=access.log

awk '{print $ 1}' $ file | sort | uniq -c | sort -nr
Summary: The study is to use awk, sort, uniq command

Guess you like

Origin blog.51cto.com/9447803/2403977