Gathering IP's from a complicated log

Posted by Harry on Server Fault See other posts from Server Fault or by Harry
Published on 2012-06-06T01:33:17Z Indexed on 2012/06/06 4:42 UTC
Read the original article Hit count: 366

Filed under:
|
|
|

I have a question regarding the use of some more advanced grep, awk, sed. I have a log file, for a proprietary MTA, that contains IP's in a string, delimited by [redacted]^~x.x.x.x^[redacted]. So far all of my grepping, awking, and sedding hasn't gotten me very far.

This log file has 331520 lines in it. My goal was to simply grep out the ip's, then do a for loop with sed, to sed 's/$i/redacted'. I'm including a sample of one of the log entries. If you all have any idea, I would be greatly appreciative.

Jun  4 15:21:52 host.name mta-name: 13388^~88/CC-04671-FCA0DCF4^~D^~<redactedmessageid>^~@^[email protected]^~redacted.hostname^~000.00.000.000^~port^~esmtp^~^~external_routing_nobounce^~0^~0.51^~subjectofmessage^~250 2.6.0 <redactedmessageid> [InternalId=2178458] Queued mail for delivery    

© Server Fault or respective owner

Related posts about logging

Related posts about grep