I have myfile.conf with this content:

ServerAlias *.mysite.com

I'm trying to convert to:

ServerAlias *.xxmysite.com

but I get:

ServerAlias *.xx.mobilsem.com

areemplazar="ServerAlias *."
reemplazo="ServerAlias *.xx"
sed -i ''  -- "s|${areemplazar}|${reemplazo}|g"  ./myfile.conf

When I use escape points like "ServerAlias *." , there is no reeplace.

What am I doing wrong ?


Period . and asterisk * as regex metacharacters should be escaped to treat them literally:

Sample input file:

$ cat input.txt
ServerAlias *.mysite.com

sed 's/ServerAlias \*\./&xx/' input.txt
ServerAlias *.xxmysite.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.