procmail
[Top] [All Lists]

Re: Follow: Recipe woes

2003-06-01 13:14:55
Justin is trying to use this extended sed syntax:

sed -e "s/(user1|user2)/spamreportuser/gi"

To test this I'm simply cating a file at the command line containing

user1
User1
user2
User2

... and getting no substitutions. (That he should redirect the file and not cat it is another issue.)

I know that's the correct syntax for egrep, awk,
and even Procmail.

Not for plain sed, though. It uses the basic regexps of grep (except that \n can represent an embedded newline in a search pattern -- but not in a substition pattern). Also, it doesn't grok the /i modifier.

  sed "s/[Uu]ser[12]/spamreportuser/g"

is about as close as you'll get with a straight, unenhanced sed. If the alternatives are not choices among single characters, then,

  sed -e "s/User1/spamreportuser/g" \
      -e "s/User2/spamreportuser/g" \
      -e "s/user1/spamreportuser/g" \
      -e "s/user2/spamreportuser/g"

My advice: get a fancier sed, one that will handle extended regular expressions and extensions like /i.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>