Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given the following procmail recipe:

* ^Subject:.*viagra.*
* ^From:.*viagra.*

Procmail would only delete emails that were both from viagra, and had viagra in the subject. Is it possible to apply the filter if either of the matches are true?

The solution should preferably not make use of the regular expression (regex1|regex2) operation, but if that is the only solution, then please say so.

share|improve this question
up vote 5 down vote accepted

You are close. A strong understanding of regex goes a long way toward successful procmail recipes. Procmail is extremely flexible, but that flexibility depends largely on regex.

* ^(From|Cc|To|Subject).*viagara.* 

Alternately, and I believe closer to what you want to achieve, use a pipe and new line escape to continue the rule on the next line (for readability). In your example, you were creating a new condition that also had to be matched.

* ^Subject:.*viagra.* |\
share|improve this answer

Just use two recipes, each going to /dev/null, one matching on Subject, the other matching on From. The first match wins. This is essentially the same as an OR operator. The reg1|reg2 approach would work, but I think it reads more clearly as two recipes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.