AWK 命令例子

access-2018-04-25.log
2018-08-30 17:34:06.104 [vert.x-eventloop-thread-0] INFO  com.cbx.cpm.logging.CpmLoggerHandlerImpl - 127.0.0.1 - - KMT [Thu, 30 Aug 2018 17:34:06 GMT] "GET /cpm/fa893fab-c1eb-4a6a-b78e-7a1efd5ade94 HTTP/1.1" 200 6760 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_181)"
2018-08-30 17:34:06.371 [vert.x-eventloop-thread-0] INFO  com.cbx.cpm.logging.CpmLoggerHandlerImpl - 127.0.0.1 - - KMT [Thu, 30 Aug 2018 17:34:06 GMT] "POST /cpm/history/fa893fab-c1eb-4a6a-b78e-7a1efd5ade94 HTTP/1.1" 200 3593 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_181)"
command
cat access-2018-04-25.log | awk '($14!="23:59:59") {print $1 "\t" $2 "\t" $15 "\t" ((substr($2,4,2)*60 + substr($2,7,2))*1000+substr($2,10,3) - (substr($15,4,2)*60 + substr($15,7,2))*1000)/1000  "\t" $4 "\t" substr($17,2) "\t" $18 "\t" $20}' 
result
2018-08-30      17:34:06.104    17:34:06        0.104   INFO    GET     /cpm/fa893fab-c1eb-4a6a-b78e-7a1efd5ade94       200
2018-08-30      17:34:06.371    17:34:06        0.371   INFO    POST    /cpm/history/fa893fab-c1eb-4a6a-b78e-7a1efd5ade94       200
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值