35

The new line \n is not taken account in the shell strings

root@toto:~# str="aaa\nbbbb"
root@toto:~# echo $str
aaa\nbbbb

expected result:

root@toto:~# echo $str
aaa
bbbb

How to add a new line in the string?

4

1 回答 1

75
$ echo "a\nb"
a\nb
$ echo -e "a\nb"
a
b
于 2013-07-30T15:10:27.020 回答