Xref: utzoo comp.sources.wanted:10456 comp.lang.perl:303 Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!snorkelwacker!tut.cis.ohio-state.edu!ucbvax!decwrl!sun-barr!newstop!texsun!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.sources.wanted,comp.lang.perl Subject: Re: Need something to trim headers off of mail messages Message-ID: <5198@convex.convex.com> Date: 6 Feb 90 20:14:42 GMT References: <1990Feb6.153718.4546@eplrx7.uucp> Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Followup-To: comp.sources.wanted Organization: CONVEX Software Development, Richardson, TX Lines: 40 In article <1990Feb6.153718.4546@eplrx7.uucp> mcneill@eplrx7.uucp (Keith McNeill) writes: >Subject says most of it... > >I have something now called trim-headers ((C) 1986 Dave Taylor) but it gets >a little carried away now & then....it trims off the entire message. Well, if you accept that a "mail message" consists of a header and a body delimited by a blank line, a sed one-liner should do it: sed -n -e '/^$/,$p' files ... Although ctually that gives you the blank line. this one eats it sed -e '1,/^$/d' files ... If you want to actually modify the file in-place, then you might do something like this: foreach file ( files ... ) sed -e '1,/^$/d' < $file > $file.tmp && mv $file.tmp $file end or as a one-liner in perl (you knew this was coming, right? :-) perl -i -n -e 'print unless 1../^$/;' files ... or for the faint of heart desiring backup files: perl -i.bak -n -e 'print unless 1../^$/;' files ... and for the record, the keep-the-blank-line version is perl -i -n -e 'print if /^$/..eof();' files ... --tom -- Tom Christiansen {uunet,uiucdcs,sun}!convex!tchrist Convex Computer Corporation tchrist@convex.COM "EMACS belongs in : Editor too big!"