Your question is really not about programming; maybe try https://serverfault.com/ or https://unix.stackexchange.com/ for the infrastructure parts. I'll focus on answering the question in the title, though the details on that are also rather muddy.
:0fH
* domain1
| sed 's/domain1/domain2/g'
I'm guessing from your description that domain1
is actually a substring of domain2
. If that's the case, the regexes need to be sharpened a bit (or you'll end up replacing domain1inc
with domain1incinc
, etc). As a quick first approximation, doman1($|[^i])
will match domain1
when it is followed by nothing, or a character which isn't i
. When substituting, you will want to keep that character, which is usually done in sed
by remembering it, and substituting it with itself. Or you can switch to Perl, which supports a much richer regex dialect.
:0fH
* domain1($|[^i])
| perl -pe 's/domain1(?!inc)/domain2/g'
Though of course, perhaps your real use case looks more iike s/domain1.com/domain2.com/g
in which case the additional context of the .com
suffix is quite sufficient for avoiding to substitute strings which should remain unchanged, and you can safely stay with the simpler and thus faster and probably more secure sed
.
Again, how exactly to run Procmail on your incoming email in the first place is a separate topic wichwhich isn't really programming-related. If you have Postfix and Procmail on the mail server, simply creating a .procmailrc
in the helpdesk
account's home directory should suffice.