Skip to main content
2 of 3
added 134 characters in body
Hauke Laging
  • 94.6k
  • 21
  • 132
  • 185

echo puts a space between each two arguments. The shell considers the newline in $num just a word separator (just like space).

lines="a
b
c"
set -x
echo $lines   # several arguments to echo
echo "$lines" # one argument to echo

See this answer (by the OP himself) for a more detailed explanation.

Hauke Laging
  • 94.6k
  • 21
  • 132
  • 185