gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 12:40:09 26 4
gpt4 key购买 nike

新行 \n 不在 shell 字符串中考虑:

str="aaa\nbbbb"
echo $str

输出:

aaa\nbbbb

预期结果:

aaa
bbbb

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

最佳答案

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

关于linux - 如何在 Bash 字符串中添加新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17950742/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com