1

the problem is, that i cant remove the symbols { and } from strings in HTML files, inside the file the string looks like

Var @footer Set @footer = TransformXML(XML, GetPortfolioItem("Footer_EN_${et.mode}"))

and i need to remove ${et.mode} with the "newmode" text var. for example

was ("Footer_EN_${et.mode}"))
will be ("Footer_EN_my_current_mode"))

i set a var like the next one

echo -n "choose name: "
read newmode
path=/root/EN
newpath=tmp/EN_$newmode
default_text="${et.mode}"

sed -i "s/\/{et.mode}/\/$newmode/g" *.html
sed -i "s/$default_text/$newmode/g" *.html

but it doesnt work

1 Answers1

1

Try:

sed -i 's/\${et\.mode}/'"$newmode/g" *.html

You need to match the $ character literally, so it needs to be escaped. That should be done inside single quotes. The $newmode variable should be inside double quotes so it gets expanded.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • As usual in these situations it's worth mentioning that `$newmode` shouldn't contain things like ampersands, backslashes, etc. – Tom Fenech Jan 12 '16 at 23:03