sed 分析nginx 日志

阅读更多
nginx 日志格式如下:
123.159.205.213 - - [19/Feb/2016:02:59:01 +0800] "GET /telematics/v3/weather?location=%E7%8E%89%E6%BA%AA%E5%B8%82&output=json&ak=0l3FSP6qA0WbOzGRaafbmczS HTTP/1.1" 200 2154 "-" "IME/Android/4.4.2/N80.QHD.YT.IME.V3/N80.QHD.YT.IME.V3.20150928.194642" "-"

### 统计nginx日志 从2016:02:59:59 到2016:17:00:00 访问次数前十的ip,及其访问数
sed -n '/2016:02:59:59/,/2016:17:00:00/p' access.log|awk '{print $1}' |sort|uniq -c|sort -hr|sed '{11,$D; =}'|sed 'N; s/\n/ /'  ### 统计nginx日志 从2016:02:59:59 到2016:17:00:00 访问次数前十的ip,及其访问数
输出结果:
1  362462 123.159.205.213
2  352469 123.159.205.214
3  347715 123.159.205.215
4  280267 123.159.205.219
5  261969 123.159.205.218
6  167622 182.254.11.200
7  165186 182.254.11.201
8  138039 182.254.11.199
9  123804 123.159.205.220
10   93180 123.159.205.216

#### 9点到12点的访问量
sed -n '/2016:09:00:00/,/2016:12:00:00/p' access.log|wc -l

你可能感兴趣的:(nginx,sed)