linux - using awk and sed find using lines in a file based on a field value from awk -
I use a postfix relay to send my mail server to our email server.
I have to get the serial number value before some users receive an email address using the value of the e-mail they are sending. Examples of entry and entry from below are I think you have to use a combination of awk and sed.
Sender Line
4 November 14:29:53 Server Postfix / qmgr [2089]: 42UE78JD7JE: to = & lt; Sender@domain.som> ;, size = 1182, nrcpt = 1 (Qi active)
receiver line
4 November 14: 29: 54 server postfix / SMTP [10544]: 42UE78JD7JE: Too = & lt; User@gmail.com>, relay = gmail-smtp-in.l.google.com [74.125.22.27]: 25, delay = 1, delay = 0.02 / 0
In the above example, I want to remove 42UE78JD7JE from the first row and then find it in the second row. I'm thinking that you will use awk to get serial number values in line with 'sender@domain.com', then use that value to search for lines with that value and use 'to ='
awk '$ 7 ~ / ^ to = / {$ 6] = $ 7} Print from [key] to [key] from [key]} 'file [/ code>] (in the key) if ~ / ^ to = / {to [$ 6] = $ 7} Pre> to = & lt; Sender@domain.som> ;, to = & lt; User@gmail.com>,
Comments
Post a Comment