如何在bash字符串中添加新行?

时间:2013-07-30 15:08:25

标签: linux bash shell sh ash

新行\n未在shell字符串

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

预期结果:

root@toto:~# echo $str
aaa
bbbb

如何在字符串中添加新行?

1 个答案:

答案 0 :(得分:63)

$ echo "a\nb"
a\nb
$ echo -e "a\nb"
a
b