Re: need help parsing Received-SPF header



moody wrote:

Please don't top-post. Fixed below.

On Oct 18, 2:17 am, calm...@xxxxxxxxx wrote:

Using sed or awk or another such shell tool, how can I extract only the
email address from a "Received-SPF" header in a mail message?

Seehttp://www.openspf.org/newheader.htmlfor examples of what this
header looks like.

You MAY want to post a small sample input and expected output here rather than asking people to go look at some URL.

As you can see, the email address
(myn...@xxxxxxxxxxx) appears in different parts of the header and is
bounded sometimes by a character like ":" or ")" and sometimes by just
whitespace. Seems like a pretty challenging regex to me to get right.
Can anyone help?


What output you exactly want from the resulting email headers, I
suppose you want only the line containing/begining with Received-SPF
u might consider this


awk '/Received-SPF/ { print $0 } '

If that does what the OP wants, it can be written as just:

awk '/Received-SPF/'

since printing $0 is awks default action on a true condition.

Ed.
.



Relevant Pages

  • need help parsing Received-SPF header
    ... Using sed or awk or another such shell tool, how can I extract only the ... email address from a "Received-SPF" header in a mail message? ...
    (comp.unix.shell)
  • Re: need help parsing
    ... email address from a "Received-SPF" header in a mail message? ... but it assumes e-mail addresses only have letters in ...
    (comp.unix.shell)
  • Re: need help parsing Received-SPF header
    ... suppose you want only the line containing/begining with Received-SPF ... email address from a "Received-SPF" header in a mail message? ... Seems like a pretty challenging regex to me to get right. ...
    (comp.unix.shell)
  • Re: need help parsing
    ... email address from a "Received-SPF" header in a mail message? ... Seems like a pretty challenging regex to me to get right. ...
    (comp.unix.shell)
  • Re: Need help to reformat complex file
    ... I had been trying something very close to your awk suggestions, but couldn't quite get it to work. ... Then I guess it was my fault and that your header is not, ... Williams is more tolerant of additional words in the header section, but it is less tolerant of blank lines in the input file. ... Mine is intolerant of "VELSTK" appearing other than at the start of the header section, whereas Williams will tolerate it except at the start of the data lines. ...
    (comp.lang.awk)