Thursday, 22 February 2018

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.


Answer



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.



No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...