Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash echo command not making use of escaped character

The bash echo command isn't using the escaped characters like "\n" and "\t"

echo "This is test string\nAnd this is next line"

For the above input it displays

This is test string\nAnd this is next line

So how do I print on the next line?

like image 544
Kaymatrix Avatar asked Nov 28 '22 22:11

Kaymatrix


1 Answers

You need echo -e if you want escaped characters to be expanded:

$ echo -e "This is test string\nAnd this is next line"
This is test string 
And this is next line
like image 75
Paul R Avatar answered Dec 06 '22 10:12

Paul R