Linux中awk抽取包含某字段的整行日志并保存到文件

命令示例:
awk '{if($0~"listAuths") print}' xxx.log
解释说明:
抽取xxx.log整个日志文件中,包含“listAuths”的行,打印输出

抽取结果保存到文件
awk '{if($0~"listAuths") print}' xxx.log >> result.log (将结果输出到result.log文件中)


抽取效果:
[root@SZB-L0005724 applogs]# awk '{if($0~"listAuths") print}' csp_iobs_core_trace.log.2016-04-27 
[INFO ] [2016-04-27 17:40:14] com.pingan.iobs.core.aspect.ControllerAspect -  listAuths finished! cost: 4ms. args : listAuths'args : 
[INFO ] [2016-04-27 17:41:13] com.pingan.iobs.core.aspect.ControllerAspect -  listAuths finished! cost: 5ms. args : listAuths'args : 
[INFO ] [2016-04-27 17:45:14] com.pingan.iobs.core.aspect.ControllerAspect -  listAuths finished! cost: 5ms. args : listAuths'args : 
[INFO ] [2016-04-27 17:50:15] com.pingan.iobs.core.aspect.ControllerAspect -  listAuths finished! cost: 5ms. args : listAuths'args : 
[INFO ] [2016-04-27 17:55:15] com.pingan.iobs.core.aspect.ControllerAspect -  listAuths finished! cost: 5ms. args : listAuths'args : 
[INFO ] [2016-04-27 18:00:16] com.pingan.iobs.core.aspect.ControllerAspect -  listAuths finished! cost: 5ms. args : listAuths'args : 
[INFO ] [2016-04-27 18:05:16] com.pingan.iobs.core.aspect.ControllerAspect -  listAuths finished! cost: 4ms. args : listAuths'args : 






详解:http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html

  • 6
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

多来哈米

还可以打赏???来试一毛

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值