What are the differences between the three following echo commands?
var='You'
echo "Hello\nThere\n${var}"
Output:
Hello\nThere\nYou
echo 'Hello\nThere\n${var}'
Output:
Hello\nThere\n${var}
echo $'Hello\nThere\n${var}'
Output:
Hello
There
${var}
I understand that single ticks (i.e., '') tells echo to interpret all characters within as literals.
But I was expecting the double quotes to print the newlines, but it didn't. And I don't understand why $'' did print the new lines.
What are the differences between these commands?
echoeven starts. (The factechois a builtin in many shells does not matter). – Kamil Maciorowski Nov 30 '23 at 15:34echo $'Hello\nThere\n'$var– admstg Nov 30 '23 at 16:46