I want create simple xml file using bash script ( not with dom )
but when I set value in the line then echo print the $lorem word and not the val
lorem=LOL
echo '<root><foo a="b">$lorem</foo><bar value="ipsum" /></root>' >> $MY_XML
I also try this
echo '<root><foo a="b">\$lorem</foo><bar value="ipsum" /></root>' >> $MY_XML
echo '<root><foo a="b">"$lorem"</foo><bar value="ipsum" /></root>' >> $MY_XML
echo '<root><foo a="b">\"$lorem\"</foo><bar value="ipsum" /></root>' >> $MY_XML
but all these print the exactly the line and not the val
please advice how to print the val $lorem ? as the following example
<root><foo a="b">LOL</foo><bar value="ipsum" /></root>
Best Answer
Print the line on this way:
This is need because single quotes deny shell interpreter from replace environment variables inside