Skip to main content
added 1 character in body
Source Link
tripleee
  • 188.7k
  • 36
  • 311
  • 359

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.

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 wich 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.

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 which 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.

added 42 characters in body
Source Link
tripleee
  • 188.7k
  • 36
  • 311
  • 359

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 wich 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.

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. 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'

Again, how exactly to run Procmail on your incoming email in the first place is a separate topic wich 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.

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 wich 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.

added 42 characters in body
Source Link
tripleee
  • 188.7k
  • 36
  • 311
  • 359

Your question is really not about programming; maybe try [sf]https://serverfault.com/ or [unix.se]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
* domain2domain1
| sed 's/domain1/domain2/g'

I'm guessing from your description that domain2domain1 is actually a substring of domain1domain2. If that's the case, the regexes need to be sharpened a bit. As a quick first approximation, doman2doman1($|[^i]) will match domain2domain1 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
* domain2domain1($|[^i])
| perl -pe 's/domain2domain1(?!inc)/domain1domain2/g'

Again, how exactly to run Procmail on your incoming email in the first place is a separate topic wich 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.

Your question is really not about programming; maybe try [sf] or [unix.se] for the infrastructure parts. I'll focus on answering the question in the title, though the details on that are also rather muddy.

:0fH
* domain2
| sed 's/domain1/domain2/g'

I'm guessing from your description that domain2 is actually a substring of domain1. If that's the case, the regexes need to be sharpened a bit. As a quick first approximation, doman2($|[^i]) will match domain2 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
* domain2($|[^i])
| perl -pe 's/domain2(?!inc)/domain1/g'

Again, how exactly to run Procmail on your incoming email in the first place is a separate topic wich 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.

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. 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'

Again, how exactly to run Procmail on your incoming email in the first place is a separate topic wich 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.

Source Link
tripleee
  • 188.7k
  • 36
  • 311
  • 359
Loading