Bash – Echo newline in Bash prints literal \n


In Bash, tried this:

echo -e "Hello,\nWorld!"

But it doesn't print a newline, only \n. How can I make it print the newline?

I'm using UbuntuĀ 11.04 (Natty Narwhal).

Best Solution

You could use printf instead:

printf "hello\nworld\n"

printf has more consistent behavior than echo. The behavior of echo varies greatly between different versions.