Linux中awk抽取包含某字段的整行日誌

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


抽取效果:
[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
————————————————
版權聲明:本文爲CSDN博主「多來哈米」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/hgg923/article/details/51376295

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章