procmail
[Top] [All Lists]

Re: formail -D generates empty msg. when duplicate found?

1999-12-12 13:51:45
When I suggested this, based on an old post from Stephen,

T>   formail -D 10000 id.cache -I'From x' -x'From ' -s < mbox | wc -l

Gary asked,

F> Hate to ask, but how does this work?

On any message that is not found to be a duplicate, formail will change
the "From " line to "From x" and output only the "From " line without the
fieldname.  In other words, you'll get "x<newline>" for each message that was
not a duplicate and nothing for messages that are duplicates.

| Won't this count all messages?

It processes all messages, but the duplicates come out as null, so wc sees
nothing to count for them.

| Or is the -s call suppressed by the presence of -I?

No; it is tricked by the presence of -x.

The -s has no program to call, so it just spits output to stdout instead
of invoking a program on it.  When it encounters a duplicate, it outputs
nothing, not even a newline, so it won't increase the line count that wc -l
will report.  If you're concerned about getting a blank line from a duplicate
message, change wc -l to wc -w, and it will count only the x's, but it works
with -l.

On the other hand, this,

  formail -D 10000 id.cache -I'From x' -x'From ' -s wc -l < mbox

reports something for every message, even the duplicates (1 if it is not a
duplicate, 0 if it is).