On Thu, 28 Apr 2005 10:20 pm, Ruud H.G. van Tol wrote:
Peter Jones:
[snip]
PATTERN... I couldn't find any egrep option which would do that for
me -- hence the PERL script...
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file con-
tains zero patterns, and therfore matches nothing.
Yes, I took a long look at egrep -f before I made my last post. (Sorry, I
should have said.) Given the required "egrep PATTERN FILE", you can
replace "PATTERN" with "-f blacklist", but you still have the requirement
that what you are trying to match (in this case my $MATCH variable) is
expected to be in a FILE.
Um...
One can always get around that, I suppose, by piping it in. The following
procmail pattern would seem to work:
:0
* ^Subject:.*\/[^ ].*
* ? echo "$MATCH" |/bin/egrep -if $BLACKLIST
.Junk.Subject/
It seems to me that this is starting to get almost as expensive as a PERL
script? However, I stand corrected that it can indeed be done with
egrep! I obviously didn't think hard enough about how to get egrep
working the first time around...
One particularly important factor, however -- which will certainly keep me
using the PERL script rather than egrep in this instance -- is that,
using egrep, you must ensure that your blacklist file does NOT end with
an empty line (the final word MUST NOT be followed by a line feed!) or
the empty line will match anything thrown at it. This is a problem for
me because I am used to working with a couple of programs (and
programming environments) which would refuse to properly read the final
line if it did not end in a line feed (or a CR-LF combo, anyway! :-))
Thus it is habit for me to include that final line feed, and sooner or
later I'd get bitten by it. (You'll note my PERL script specifically
checks for and discards an empty line in the pattern file!)
If the patterns in your patterns-file are fixed strings without
special regexp-features like [iI] .* etc., then also see -F.
The -w or -x options can speed-up things.
Thanks for the pointers -- and the lesson! :-)
Cheers,
Pete.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail