shell bash add tag
prabhjot drake
I'm using a variable that contains multi-line string. When I write 

echo -n "This is a two

line string."

`echo -n` does not suppress newline. So far as I know `-n` ( or `\c` on some systems) suppresses newlines. What I'm missing?

PS: OS: Linux Mint
Bash version

`GNU bash, version 4.4.20(1)-release (i686-pc-linux-gnu)`
Top Answer
As noted in the [`echo` man page](, `-n` suppresses only the final trailing newline

> -n
> do not output the trailing newline

If you you want to remove the newline character from the body of a block of text, [`tr`]( is the function for you. In the following example the `-d` flag indicates we should delete all instances of the selected character `\n` which is interpreted as "newline". Note the `-n` flag on `echo` is optional in this usage.

echo -n "This is a two

line string." | tr -d '\n'


![Screenshot 2020-08-25 at 20.26.27.png](/image?hash=7ab08f87c036d70baf75785832d0959750cd8027f2e6f9d81f86910dbab49945)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.