1月 202017
 

使用AWK对日志中的列进行处理

awk '$11="";{print $0}' www.access.log.20170119 > www.log.20170119
awk '$NF="";{print}' www.log.20170119 > wwww.20170119

已开启Nginx日志$request_body输出

101.28.172.41 - - [19/Jan/2017:00:00:08 +0800] "POST /api/cash/request/datareceive HTTP/1.1" 200 306 
data=disjddVLpuifVtaEdDDp28EEKLHhTtTmmkNBJnmKu7ALTHoF7j4W7aX31NLpVHN46WmvJj2UZ5G762ZorivmMEhyhoGlW6TeEWoqGkljWbuS9vEzAzr9AA 
gUPqghPTnGFLRvzL7Ty4%2BEEuzXOcqST%2BYMjvNLqsHAHSF7TauREm8%3D& "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" "-"

使用Awk删除指定列后,重新输出最新内容并重定向至文件,处理掉包含$request_body输出的部分后,产生了一个连续空格符号

101.28.172.41 - - [19/Jan/2017:00:00:08 +0800] "POST /api/cash/request/datareceive HTTP/1.1" 200 306 "-" 
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" "-"

再次使用awk输出所有列并重定向至文件

101.28.172.41 - - [19/Jan/2017:00:00:08 +0800] "POST /api/cash/request/datareceive HTTP/1.1" 200 306 "-" 
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" "-"

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据