| Date: Sun, 11 Jul 2004 10:48:58 +0100
| From: <olearypj at rte.ie>
|
| I need to delete the header & keep the body of an email,
| I tried it with the following sed command,
| sed '1,/^$/d' email > emailbody.txt
| to delete from the first line up to the first white space,
that sed(1) command deletes all lines from
the very first to and including first line
which is _empty_.
"whitespace" is nominally considered the set
of characters space, (horizontal) tab, usually
newline, and often also vertical tab, form feed,
and carriage return. if you want to delete up
until one of those characters, you'll need to
use a rather different sed script ....
.... BUT you do not, as yer original actually _is_
what you want, it is just the description which is
misleading. ;-)
| but all I get is an empty emailbody.txt.
as to what is going wrong, it must(?) be the case
that either the input `email' is empty (unlikely);
or that the input does not contain a truly empty
line at all --- then sed will search for one until
the end, outputting nothing, and quit. end result
is an empty output file.
so if it _looks_ like you have empty lines, then
it must be an "invisible" character. and in this
particular case, carriage return (^M, CR, \r, or
U+000D) is the most likely candidate. check with
od(1), hexdump(1) or similar.
( I've no idea if a ^M on that separating line is
legal or not? I have_not_ been able to find an
example in a survey of c.4000 messages, so I am
a bit puzzled here .... and as such, I do not
see anything wrong with either the sed script or
the algorithm .... )
cheers!
-blf-
--
«How many surrealists does it take to | Brian Foster Montpellier,
change a lightbulb? Three. One calms | blf at utvinternet.ie FRANCE
the warthog, and two fill the bathtub | Stop E$$o (ExxonMobile)!
with brightly-colored machine tools.» | http://www.stopesso.com
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!