notorious has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to run an expression to match a particular line of text in a file, then capture the entire rest of the file using a perl one-liner:
For example, in the following file, I want to match starting at Header2 (ie the first header after ".X-Intermail-Unknown-MIME-Type=unparsedmessage" to the end of the file.
<lsmothers@example.com> SMTP 0<001501c4db9b$db8b2680$2d01a8c0@ryand9v889t9uc> .X-Intermail-Unknown-MIME-Type=unparsedmessage Header2: <headertwo@example.com Received: from server.cluster1.example.com ([10.20.201.160]) line 12
EVERYTHING I have done around this does not catch it. An example of what I have tried is below. From what I read, I think the below method should work:
$ cat sample.txt | perl -wnl -e '/\.X\-Intermail\-Unknown\-MIME\-Type\ +=unparsedmessag(e.*)/s and print $1;' e
The above returns only the e character, and I did that on purpose to make sure the string is matched. I am using the s modifier after the expression, which would categorize "newline" as "any".
Can anyone give me any suggestions? Thanks, Robert
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regular expression - grabbing everything problem
by davido (Cardinal) on Aug 09, 2011 at 00:16 UTC | |
by jwkrahn (Abbot) on Aug 09, 2011 at 00:42 UTC | |
by davido (Cardinal) on Aug 09, 2011 at 00:53 UTC | |
|
Re: regular expression - grabbing everything problem
by jwkrahn (Abbot) on Aug 09, 2011 at 00:48 UTC | |
|
Re: regular expression - grabbing everything problem
by shmem (Chancellor) on Aug 09, 2011 at 03:13 UTC | |
|
Re: regular expression - grabbing everything problem
by JavaFan (Canon) on Aug 09, 2011 at 08:36 UTC | |
by notorious (Initiate) on Aug 09, 2011 at 21:58 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |