Subject: Adding a "Lines:" header

From: Joe Hildebrand <[email-masked]>
Date: Fri, 13 Jan 1995 10:59:57 -0500

Is there a better way to add a "Lines:" header to mails that don't
already have one?  For example, I'd rather have a count of just the
number of lines in the body, instead of the length of the entire
message.

:0
* !^Lines:
{
   MAIL_LENGTH=`wc -l`
   
   :0f
   | formail -a "Lines: $MAIL_LENGTH"
}

-- 
Joe Hildebrand                  Fuentez Systems Concepts
[email-masked]              11781 Lee-Jackson Hwy, Suite 700
Senior Software Engineer        Fairfax, VA 22033
                                Phone:    (703)273-1447   
                                Fax:      (703)273-2972
                                PGPprint: 0x06C96661

Standard disclaimers apply

---

From: [email-masked] (Stephen R. van den Berg)
Date: Fri, 13 Jan 1995 20:06:50 +0100

Joe Hildebrand <[email-masked]> wrote:
>already have one?

It depends on the size of the mail.
With small mails it is faster to have procmail count the lines "inline".
Above a certain size (the actual limit will depend on machine architecture,
operating system and compiler) 'wc' should be faster than procmail.

You can make procmail do the counting like this:

:0 fhw
* !^Lines:
* B ?? 1^1 ^(.|$)
| formail -a "Lines: $="

Or, if you find that clearer (there is no difference in speed):

:0
* !^Lines:
{
  :0 B
  * 1^1 ^(.|$)
  {
    LINES=$=

    :0 fhw
    | formail -a "Lines: $LINES"
  }
}

If you even change the regexp from "^(.|$)" to "^." you get the added
benefit (?) that it only counts non-empty lines.

-- 
Sincerely,                                  [email-masked]
           Stephen R. van den Berg (AKA BuGless).

You should use contraceptives at every conceivable occasion.