Article View: comp.editors
Article #4040[sed] Deleting Received: headers from file
From: Charles Calvert
Date: Sat, 04 Aug 2001 00:11
Date: Sat, 04 Aug 2001 00:11
40 lines
2168 bytes
2168 bytes
I'm using GNU sed 3.02 recompiled for Win32.
I'd like to write a sed script that removes all Received: headers from
a mail message in a file. It should work with headers that span 0..N
lines. I spent some time searching the web and DejaGoogle today and
didn't find anything that does what I want or imparted enough of a
clue for me to figure it out.
I've just started using sed, so if my current attempt looks idiotic,
that's why.
Here's the script I've written.
/^Received:.*/{
:START
d
n
/^[[:space:]].*/{b START}
}
I think that it should do the following:
if matches expression "^Received:.*"
delete the current line
read in the next line
if matches expression "^[[:space:]].*"
go to START
else
output current line
The actual result is that it strips the first line of a multiline
Received header, but leaves any subsequent lines belonging to that
header. I've probably been staring at it too long, but I can't see
what I'm doing wrongly.
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research
Technical Details
Message-ID:
<0qemmtcr1t6u6lfmqvt87kvn10jgk51u5p@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!feed1.news.rcn.net!rcn!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109f73,f5da5342e4a193e2,start X-Google-Attributes: gid109f73,public X-Google-Thread: 107393,f5da5342e4a193e2,start X-Google-Attributes: gid107393,public X-Google-ArrivalTime: 2001-08-03 17:13:01 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!feed1.news.rcn.net!rcn!not-for-mail From: Charles Calvert <cbciv@yahoo.com> Newsgroups: comp.editors,gnu.utils.help Subject: [sed] Deleting Received: headers from file Date: Fri, 03 Aug 2001 20:11:37 -0400 Lines: 40 Message-ID: <0qemmtcr1t6u6lfmqvt87kvn10jgk51u5p@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: UmFuZG9tSVYh7tdRcJZbseyUIWJvsaJ4N01wnmADsvKbp5DzExXQMx3N24T6avZw X-Complaints-To: abuse@rcn.com NNTP-Posting-Date: 4 Aug 2001 00:12:41 GMT X-Newsreader: Forte Agent 1.8/32.548