Search code examples
bashechonewline

Echo newline in Bash prints literal \n


How do I print a newline? This merely prints \n:

$ echo -e "Hello,\nWorld!"
Hello,\nWorld!

Solution

  • Use printf instead:

    printf "hello\nworld\n"
    

    printf behaves more consistently across different environments than echo.