echo
puts in a newline character at the end of its output, which tr
is converting. This is often the desired behavior, hence it being the default. Imagine echo hello
on the terminal; you want a newline there so your prompt returns.
You can use the -n
option to echo
to fix the above behavior. This information can be found in man 1 echo
:
-n do not output the trailing newline