Regarding: mailbox (mbox format) email messages
Multi Message File: Inbox.mbox
From - Thu Mar 26 16:16:21 2015
From: Mail Delivery System <Mailer-Daemon@200.netwizz.com>
To: edge@notterribe.org
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1Yb3yX-0004CB-QH@200.netwizz.com>
Date: Thu, 26 Mar 2015 02:21:17 -0700
Date: Thu, 26 Mar 2015 02:20:44 -0700
From: edge <edge@notterribe.org>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0
MIME-Version: 1.0
To: leasing@theedgehenderson.com
CC: etpmgr@movein.net, t.simmonds@movein.ne
Subject: Fwd: Today's Breach Of Our Security.
From - Fri Mar 27 12:00:00 2015
Desired Pattern Match Order;
Date: Thu, 26 Mar 2015 02:21:17 -0700
From - Thu Mar 26 16:16:21 2015
From: Mail Delivery System <Mailer-Daemon@200.netwizz.com>
To: edge@notterribe.org
Message-Id: <E1Yb3yX-0004CB-QH@200.netwizz.com>
Subject: Mail delivery failed: returning message to sender
Desired Final Result;
Date: Thu; 26 Mar 2015 02:21:17 -0700;From - Thu Mar 26 16:16:21 2015;From: Mail Delivery System <Mailer-Daemon@200.netwizz.com>;To: edge@notterribe.org;Message-Id: <E1Yb3yX-0004CB-QH@200.netwizz.com>;Subject: Mail delivery failed: returning message to sender
Objectives;
* Each mail message in "Inbox.mbox" starts with "From "
* Match 1st occurance once only for "^Date: |^From |^From: |^To: |^Message-Id: |^Subject: ", print that line.
* Format Output results in csv seperated by semicolon
I've tried;
grep -a -E -i "^Date: |^From |^From: |^To: |^Message-ID: |^Subject: " Inbox.mbox
awk '/^Date: / || /^From / || /^From: / || /^To: / || /^Message-ID: / || /^Subject: /' Inbox.mbox
Comments: The above gave me a good start, I'm most familiar with awk and grep so I'm trying to use them only. Having difficulty printing out the lines in order I wish, matching the 1st occurance only ending in a newline. Binary data existed in some messages so I used -a with grep.
Any assistance would be most appreciated.
Thank you.
Aucun commentaire:
Enregistrer un commentaire