Echo text without a trailing newline


By default the echo command will include a trailing newline at the end of a string. There are many times when you may want to suppress this newline for example when you want to format text in a certain way.There are a couple easy ways to do this.

First you can use the ‘-n’ option.
$ echo -n "hello"

You can also use the ‘-e’ option which enables interpretation of backslash escapes. Followed by a ‘\c’ escape character to signal continuation (no automatic line break).
$ echo -e "hello\c"