首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用awk解析日志条目

使用awk解析日志条目
EN

Stack Overflow用户
提问于 2013-11-14 09:30:45
回答 2查看 251关注 0票数 3

我得到了以下日志:

代码语言:javascript
复制
2013-10-24 18:35:49,728 ERROR [xx.xx.xx.xx.xx.xx] (xx.xx.xx.xx.xx) Manila Olongapo Leyte Tacloban has updated their subscriber details. But, the Regional Account Update interface call has failed for the following Local Registries: <br/>Visayas<br/>Data between LRA and the above Local Registries is out of synch as a result.

我希望结果输入采用以下格式。做这件事的更好的方法是什么?- using awk还是sed?请给我建议。

代码语言:javascript
复制
$Province$ has updated their subscriber details. However, the Customer Account Update interface call has failed for the following Land Registries:
$Region Name$
EN

回答 2

Stack Overflow用户

发布于 2014-05-14 01:24:56

考虑到你的一行例子,并且只想p̶o̶o̶r̶l̶y̶回答你的问题,它是这样的:

代码语言:javascript
复制
echo '2013-10-24 18:35:49,728 ERROR [xx.xx.xx.xx.xx.xx] (xx.xx.xx.xx.xx) Manila Olongapo Leyte Tacloban has updated their subscriber details. But, the Regional Account Update interface call has failed for the following Local Registries: <br/>Visayas<br/>Data between LRA and the above Local Registries is out of synch as a result.'  | awk '{print $6,$7,$8,$9,$10,$11,$12,$13,$14,"However, the Customer",$18,$19,$20,$21,$22,$23,$24,$25,$26,"Land",$28,substr($29,6,7)}'
票数 1
EN

Stack Overflow用户

发布于 2014-04-16 13:42:37

这在sed中很容易做到

代码语言:javascript
复制
sed -r '
    s#(^.*\) |<br/>Data.*$)##g;
    s/But/However/;
    s/Regional/Customer/;
    s/Local/Land/;
    s# <br/>#\n#
' input.log
Manila Olongapo Leyte Tacloban has updated their subscriber details. However, the Customer Account Update interface call has failed for the following Land Registries:
Visayas
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19967850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档