The arguments of the echo commands should be in (double-)quotes.
echo -e "$var"
Then $var
is substituted but no further expansions occur - spaces are printed.
But you should really prefer printf
over echo
.
printf
uses a first argument as a format string that specifies how the following arguments are treated.
2 Likes