This discussion is archived
12 Replies Latest reply: Aug 21, 2009 12:12 AM by r035198x RSS

Help with pattern matching

549379 Newbie
Currently Being Moderated
Hi,

I have an input text file which contains the records as below.
n3TJjStl002090::Apr 29 15:45:28 arella sm-mta[2090]: [ID 801593 mail.info] n3TJjStl002090: Subject:HP.License.Authorization,AAC#.D3C77MFLB5XM8S52F31P,PO#.60-M5656,SO#.63199162
 Apr 29 15:45:28 arella sm-mta[2118]: [ID 801593 mail.info] n3TJjStl002090: to=<licensefulfillment@mail.corp.hp.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=129622, relay=corpussmtp3.corp.hp.com. [10.254.64.53], dsn=2.0.0, stat=Sent ( <N6fFJ4Uvw00000658@CORPUSMX80A.corp.hp.com> Queued mail for delivery)
++++++++++++++++++++++++++
n3TJjStl002090::Apr 29 15:45:28 arella sm-mta[2090]: [ID 801593 mail.info] n3TJjStl00209:Subject:Out.of.Office.AutoReply:HP.License.Authorization#.D3C77MFLB5XM8S52F31P,PO#.60-M5656,SO#.63199162
++++++++++++++++++++++++++
n3TJjStl002090::Apr 29 15:45:28 arella sm-mta[2090]: [ID 801593 mail.info] n3TJjStl002090: Subject:HP.License.Authorization,AAC#.D3C77MFLB5XM8S52F31P,PO#.60-M5656,SO#.63199162
 Apr 29 15:46:33 arella sm-mta[2153]: [ID 801593 mail.info] n3TJjV6u002136: to=<bbassi@struct.com>, delay=00:01:01, xdelay=00:00:48, mailer=esmtp, pri=187269, relay=struct.com.inbound15.mxlogicmx.net. [208.65.144.12], dsn=2.0.0, stat=Sent (Backend Replied [79ea8f94.3390610320.179680.00-049.p02c11m084.mxlogic.net]: .6.0  <200904291945.n3T (Mode: normal))
++++++++++++++++++++++++++
I should look only for the record which contains the pattern Subject:HP.License.Authorization,AAC#
So the above file has two records which contains that pattern. I should pick and append them into a new file(Out.log) ignoring the other patterns from the input text file.

The out.log file should be like below:
n3TJjStl002090::Apr 29 15:45:28 arella sm-mta[2090]: [ID 801593 mail.info] n3TJjStl002090: Subject:HP.License.Authorization,AAC#.D3C77MFLB5XM8S52F31P,PO#.60-M5656,SO#.63199162
 Apr 29 15:45:28 arella sm-mta[2118]: [ID 801593 mail.info] n3TJjStl002090: to=<licensefulfillment@mail.corp.hp.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=129622, relay=corpussmtp3.corp.hp.com. [10.254.64.53], dsn=2.0.0, stat=Sent ( <N6fFJ4Uvw00000658@CORPUSMX80A.corp.hp.com> Queued mail for delivery)
++++++++++++++++++++++++++
n3TJjStl002090::Apr 29 15:45:28 arella sm-mta[2090]: [ID 801593 mail.info] n3TJjStl002090: Subject:HP.License.Authorization,AAC#.D3C77MFLB5XM8S52F31P,PO#.60-M5656,SO#.63199162
 Apr 29 15:46:33 arella sm-mta[2153]: [ID 801593 mail.info] n3TJjV6u002136: to=<bbassi@struct.com>, delay=00:01:01, xdelay=00:00:48, mailer=esmtp, pri=187269, relay=struct.com.inbound15.mxlogicmx.net. [208.65.144.12], dsn=2.0.0, stat=Sent (Backend Replied [79ea8f94.3390610320.179680.00-049.p02c11m084.mxlogic.net]: .6.0  <200904291945.n3T (Mode: normal))
++++++++++++++++++++++++++
Could you help me out to perform the above task? The constant pattern is Subject:HP.License.Authorization,AAC# and the delimiter is '++++++++++++++++++++++++++'

Appreciate your help!!
Thanks
pannar

Edited by: Pannar on Aug 20, 2009 10:15 AM

Edited by: Pannar on Aug 20, 2009 10:16 AM

Edited by: Pannar on Aug 20, 2009 10:18 AM

Edited by: Pannar on Aug 20, 2009 10:20 AM