1

I have a bash script that should edit xml file. It looks like this:

echo '<?xml version="1.0" standalone="yes"?> <url>https://${site_url}</url> ...  ' > /var/www/$site_url/system_config/config.xml

As you can see I have a variable in this script ${site_url}. The problem is that script writes variable's name in xml file, not value and it lookes like this <url>https://${site_url}</url> and should look like this: <url>https://example.com</url>. What's wrong? Rest of this script works great with this variable only echo doesn't work properly

Regular User
  • 145
  • 7

1 Answers1

1

Variables won't be expanded in single quote strings. Details can be found in this answer: https://stackoverflow.com/a/13802438/6235550

You could try this:

echo '<?xml version="1.0" standalone="yes"?> <url>https://'$site_url'</url> ...  ' > /var/www/$site_url/system_config/config.xml
sstein
  • 51
  • 4
  • Duplicative questions should be closed, not answered. See the _Answer Well-Asked Questions_ section of [How to Answer](https://stackoverflow.com/help/how-to-answer). – Charles Duffy Oct 19 '22 at 18:08