Consider the two commands,
command1="mysql -umyuser -pmypassword -e \"show databases;\";"
command2="cat stackoverflow.txt"
The strings are formed as follows,
echo ${command1} -> mysql -umyuser -pmypassword -e "show databases;";
echo ${command2} -> cat stackoverflow.txt
My aim is to run the command from a variable and store it's result in another.
So what I do is,
result1=`${command1}`
ERROR 1049 (42000): Unknown database 'databases;";'
BUT,
result2=`${command2}`
works perfectly fine.
When using $()
instead of backticks the commands behave the same.
Both, of these commands work perfectly fine when run directly in backquotes instead of a variable.
Why this different behaviour?