When I run this…
echo "
fdsfsd
dsfsdf
"
I really get the output of all these lines.
However, if I use this output as an argument for echo again…:
echo "$(echo "
fdsfsd
dsfsdf
")"
…I do only get the leading new lines, not the trailing ones:
(4 empty lines)
fdsfsd
dsfsdf
So: Why does this happen? (Note I explicitly quoted the output of the $(), so I thought that would prevent such things.)
And how can I prevent this?
(tested with zsh)
BTW, same result if I use printf instead of echo – although the former obviously always misses the last line break echo would usually add.