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

dev*_*per 32 linux bash shell sh ash

\nshell字符串中不考虑新行

root@toto:~# str="aaa\nbbbb"
root@toto:~# echo $str
aaa\nbbbb
Run Code Online (Sandbox Code Playgroud)

预期结果:

root@toto:~# echo $str
aaa
bbbb
Run Code Online (Sandbox Code Playgroud)

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

Ada*_*ion 67

$ echo "a\nb"
a\nb
$ echo -e "a\nb"
a
b
Run Code Online (Sandbox Code Playgroud)