1

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 ?

1 Answer 1

2

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.