Description
<ol>
<li>A mailbox contains one more more messages.
<li>Each message contains <u>one or more</u> 'Received:' headers.
<li>A 'Received:' header consists of <u>one or more</u> lines.
The second and following ones are indented by spaces or tabs.
<li>In a message, no 'Received:' header is separated from other 'Received:'
headers by non-'Received:' headers.
</ol>
|
| Raw Input
| From sed-users@yahoogroups.com Sun May 9 14:52:11 2004
Return-Path: <sentto-changyj=rtfiber.com.tw@returns.groups.yahoo.com>
Received: from n11.grp.scd.yahoo.com (n11.grp.scd.yahoo.com [66.218.66.66])
by main.rtfiber.com.tw (8.11.6/8.11.6) with SMTP id i170Lq809415
for <changyj@rtfiber.com.tw>; Sat, 7 Feb 2004 08:21:52 +0800
Received: (qmail 74534 invoked from network); 7 Feb 2004 00:21:52 -0000
Received: from unknown (HELO n17.grp.scd.yahoo.com) (66.218.66.72)
by mta2.grp.scd.yahoo.com with SMTP; 7 Feb 2004 00:21:51 -0000
To: sed-users@yahoogroups.com
From: "john_vdv" <jvdv@spam.net>
Welcome to the world of Regular Expressions!
From tester@cracker.org Sun May 9 14:52:11 2004
Return-Path: <tester@cracker.org>
Received: from solomon.hq (solomon.hq [127.0.0.1])
by solomon.hq (Postfix) with SMTP id 355263025A
for <changyj@localhost.localdomain>
Date: Sun, 9 May 2004 14:51:57 +0800 (CST)
From: tester@cracker.org
To: undisclosed-recipients:;
Regular expressions are powerful!
|
|
| Desired Output
| Received: from n11.grp.scd.yahoo.com (n11.grp.scd.yahoo.com [66.218.66.66])
by main.rtfiber.com.tw (8.11.6/8.11.6) with SMTP id i170Lq809415
for <changyj@rtfiber.com.tw>; Sat, 7 Feb 2004 08:21:52 +0800
Received: (qmail 74534 invoked from network); 7 Feb 2004 00:21:52 -0000
Received: from unknown (HELO n17.grp.scd.yahoo.com) (66.218.66.72)
by mta2.grp.scd.yahoo.com with SMTP; 7 Feb 2004 00:21:51 -0000
Received: from solomon.hq (solomon.hq [127.0.0.1])
by solomon.hq (Postfix) with SMTP id 355263025A
for <changyj@localhost.localdomain>
|
|
Script and Comments
Script1 [ 1] /^Received:/!d
[ 2] :loop
[ 3] N
[ 4] /\nReceived:[^\n]*$/b loop
[ 5] /\n[\t ][^\n]*$/b loop
[ 6] s/\n[^\n]*$/\n/
| |