procmail
[Top] [All Lists]

preparing $VAR for use by sed

1997-10-16 10:45:05
Era Eriksson wrote,

|   I've been simulating $\VAR in sed for some cases where I wanted to
| use the result as a sed regex (can't use $\VAR directly because of the
| leading @&$0f!! parens):

|     # Simulate $\MATCH quoting for sed
|     IP=`echo "$MATCH" | sed -e 's/[][().]/\\\&/g'`

No need for a sed before the sed:

      PRE_IP=$\VAR

      :0
      * PRE_IP ?? ^^\(\)\/.*
      { IP=$MATCH }