Issue
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
Solution
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
Answered By - sstein Answer Checked By - Cary Denson (WPSolving Admin)