user2990123
user2990123

Reputation: 47

Parsing log entries using awk

I get the below logs:

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.

I want the result input to be in the below format. What is the better way to do this — using awk or sed perhaps? Please advise.

$Province$ has updated their subscriber details. However, the Customer Account Update interface call has failed for the following Land Registries:
$Region Name$

Upvotes: 3

Views: 281

Answers (2)

Marcel
Marcel

Reputation: 1286

Considering just your ONE line of example, and just to p̶o̶o̶r̶l̶y̶ answer your question, here it goes:

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)}'

Upvotes: 1

user918938
user918938

Reputation:

That's pretty easy to do in sed:

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

Upvotes: 0

Related Questions