awk取日志 指定时间段内的数据


http://bbs.51cto.com/thread-1074941-1-1.html

# Time: 130912 10:08:43
# User@Host: root[root] @ [91]
# Query_time: 15.407717 Lock_time: 0.000096 Rows_sent: 262 Rows_examined: 262
use test;
SET timestamp=1378951723;
SHOW TABLE STATUS FROM `test`;
# Time: 130912 10:09:38
# User@Host: root[root] @ [91]
# Query_time: 5.250068 Lock_time: 0.000097 Rows_sent: 2000 Rows_examined: 212687
SET timestamp=1378951778;
SELECT distinct(package_name),aid, package_id, label, short_desc, version_code , version_name, display_version_name, tt_signature, dev_name, dev_phone, dev_email, client_category FROM `test` where tt_state = 1 order by download_count desc limit 0,2000;
# Time: 130912 10:10:02
# User@Host: root[root] @ [91]
# Query_time: 5.244050 Lock_time: 0.000271 Rows_sent: 21865 Rows_examined: 219487
SET timestamp=1378951802;
SELECT
DISTINCT mp.pkg_id AS pkgId, ms.aid
FROM

上面为一部分log

现在想取 130912 10:09:00 到 130912 10:11:00 这段时间内的数据,该怎么取,日志不是一行一个,有的是一个时间有很多行,求解

 

 

awk '/^# Time: 130912/ {slow=($NF>"10:09:00" && $NF<"10:11:00")}slow' slow.log

 

awk 'BEGIN{RS="# Time: 130912"}$1>"10:09:00"&&$1<"10:11:00"{print RS,$0}'


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM