Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 012010

How to print out a newline character using the echo command?


If you try

echo "foo\nbar"

It will print out


But if you want the two words separate by an actual newline, you can use

echo -e "foo\nbar"

Output would be


You can combine the "-e" flag with other control characters such as "\t", "\r", "\v"... as well.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>