根据时间段查询log日志,拆分日志等
示例一: 日志格式: wechat_Log:[2014-09-17 09:09:22] WARN JSONObject:446 - Tried to assign property wechat_Log:[2014-09-17 09:09:22] WARN JSONObject:446 - Tried to assign property wechat_Log:[2014-09-17 09:09:22] WARN JSONObject:446 - Tried to assign property wechat_Log:[2014-09-17 09:09:22] WARN JSONObject:446 - Tried to assign property wechat_Log:[2014-09-17 09:09:22] WARN JSONObject:446 - Tried to assign property wechat_Log:[2014-09-17 09:09:22] WARN JSONObject:446 - Tried to assign property
使用命令: cat info.log.2014-09-17 | grep -E '2014-09-17 09:09:[23-59]' | more
示例二: 日志格式: 00:01:59 +0800] "GET /service/images_new/ser_zdcx.jpg HTTP/1.1" 200 3471 "-" "113.105.146.7" 3297 00:01:59 +0800] "GET /service/images_new/ser_tcyl.jpg HTTP/1.1" 200 3578 "-" "113.105.146.7" 3151 00:01:59 +0800] "GET /service/images_new/ser_gprs.jpg HTTP/1.1" 200 3432 "-" "113.105.146.7" 3117 00:01:59 +0800] "GET /service/images_new/ser_jfcx.jpg HTTP/1.1" 200 3881 "-" "113.105.146.7" 2543 00:01:59 +0800] "GET /service/images_new/ser_yytcx.jpg HTTP/1.1" 200 3986 "-" "113.105.146.7" 2893 00:01:59 +0800] "GET /service/images_new/ser_tczycx.jpg HTTP/1.1" 200 2555 "-" "113.105.146.7" 2914 00:01:59 +0800] "GET /service/adv_images/ad/20141106000553276.jpg HTTP/1.1" 200 19412 "-" "113.105.146.7" 4509 00:01:59 +0800] "GET /service/adv_images/ad/20141118164935255.jpg HTTP/1.1" 200 13745 "-" "113.105.146.7" 3787 00:01:59 +0800] "GET /service/images_new/hsj_100_1212.bmp HTTP/1.1" 200 6138 "-" "113.105.146.7" 2752 00:01:59 +0800] "GET /service/adv_images/ad/20141105235722903.jpg HTTP/1.1" 200 30682 "-" "113.105.146.7" 4965 00:01:59 +0800] "GET /service/images_new/ser_zxdx.jpg HTTP/1.1" 200 3557 "-" "113.105.146.7" 2837 00:01:59 +0800] "GET /service/adv_images/ad/20141105235813229.jpg HTTP/1.1" 200 28149 "-" "113.105.146.7" 5408 00:01:59 +0800] "GET /service/images_new/ser_indsale1.jpg HTTP/1.1" 200 10553 "-" "113.105.146.7" 3016 00:01:59 +0800] "GET /service/adv_images/ad/20141105235933683.jpg HTTP/1.1" 200 42604 "-" "113.105.146.7" 5438 00:01:59 +0800] "GET /service/payfeeonline/initPage.do HTTP/1.1" 302 244 "13876691991,hi" "117.136.13.27, 120.196.212.23" 186 00:01:59 +0800] "GET /service/images_new/public_sjzf.png HTTP/1.1" 200 2321 "-" "113.105.146.7" 15663 00:01:59 +0800] "GET /service/images_new/public_wxyy.png HTTP/1.1" 200 3346 "-" "113.105.146.7" 2913 00:01:59 +0800] "GET /service/images_new/ser_indsale2.jpg HTTP/1.1" 200 7276 "-" "113.105.146.7" 3007
使用命令: gawk -F: '{ printf ("%s:%s:%s\n", $2,$3,$4) }' web-20141216.log | grep -E '00:01:5[5:9]' | more
解释:先将日志按照冒号拆分,然后取时间部分以及后续字符部分,并查找00:01:5X时间的日志。