procmail
[Top] [All Lists]

Re: condition matching from a file

1997-01-21 14:17:46
I finally found how to make a condition line look to a simple single
column file for the component parts of a regular expression. The file
'word.list' to read from looks like this:

word1
word2
word3
word4

and make it appear to the regex as:

        word1|word2|word3|word4

The condition line I used is:

        * $"`cat word.list | awk '(NR>1){printf("|")};{printf($1)}'`"

Since I'm looking for matches to words on the list in the entire
header, the statement doesn't need anything more, the "`cmmnd`" being
taken as a regular expression. For being a bit more discriminating in
matching certain header fields:

* $^From:.*$"`cat word.list | awk '(NR>1){printf("|")};{printf($1)}'`"

The 'awk' statement was provided by my brother, the programmer. ;-)  I
know nothing about 'awk', except that this worked as needed. My
brother cautions against having whitespace in 'word.list', so if the
list includes a regex "(words and spaces)" it needs to be changed to
something like "(words.and.spaces)" or some other regex.

David

Thanks to Omegaman, Jim Dennis, Bill Moseley, and T. Bachis for their
help, and special thanks to my brother, Wm. Hunt for helping me at
unholy hours of the night while working his buns off.