How to use jsawk if every line is a json object ?

瘦欲@ 提交于 2019-12-13 04:47:10

问题


My server generated a json object for each request, so I dump that json object to a access.log file. In this case, each line of access.log is an json object. So How can I use jsawk to parse access.log ? Is there any option to switch on ?


回答1:


A good work around, use awk to preprocess the access.log like this:

$ awk 'BEGIN {print "[";}  {print $0,",";} END {print "]";}' access.log 
> | jsawk "return this.sometag"


来源:https://stackoverflow.com/questions/27117843/how-to-use-jsawk-if-every-line-is-a-json-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!