procmail
[Top] [All Lists]

Re: Separate pipes for header and body?

1998-05-20 07:25:00
#! /bin/sh

tmp=temp-file
cat - > $tmp

OK so far.

cat $tmp | sed '/^$/,$d' # This is the header
echo                     # This divides header from body

Not so good.

 sed '/^$/q' $tmp          # This gives head and blank line at neck without
                           # the extraneous cat and without reading the entire
                           # message after it knows it can stop.

If you want NOT to have the blank line in there,

 formail -X "" < $tmp
or
 sed -ne '/^$/q' -ep $tmp

cat $tmp | sed '1,/^$/d' # And this is the body, voila

Again, not so good.

 sed '1,/^$/d'             # This gives the body without the extraneous cat.

Now you can do what ever you like to.

Indeed.  What I don't understand is Dirk's unwilllingness to use two
filtering recipes, one to change the head and one to change the body, as
most of us would and as already been suggested (by Era I think).