LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   procmailrc - substitute certain words to another. (https://www.linuxquestions.org/questions/linux-software-2/procmailrc-substitute-certain-words-to-another-71752/)

drand 07-10-2003 11:50 PM

procmailrc - substitute certain words to another.
 
i need substitute certain words in From: or To: or Body to another by .procmailrc
like..
From: bla <some@la.com>, joe <fuzzy@some.com>, other <some@some.com>
Just substitute "fuzzy@some.com" by "myfirend@some.com"

fsbooks 07-11-2003 12:25 AM

Basically you can feed it through a pipe with sed (or awk, but I am better with sed. The following recipe may not work for all of the cases you are interested in, but :

:0 fwh
* ^From.*some.*com
|sed s/fuzzy@some.com/myfirend@some.com/g

This will just pass the mail along for further operation, with myfirend@some.com (did you mean myfriend? :-) substituted for fuzzy@some.com.

If you want joe <fuzzy@some.com> to go to joe@some.com (just a thought), try the following:

:0 fwh
* ^From.*joe.*some.com
|sed -e s/\ \<fuzzy//g -e s/\>//g

You need the backslashes for spaces, redirects (<,>) and of course other special characters.

Good luck, Chris


All times are GMT -5. The time now is 06:43 AM.