小编Hen*_*ley的帖子

最后的新行"$(....)"在shell脚本中被删除.为什么?

有人能解释为什么这两个命令的输出不同吗?

$ echo "NewLine1\nNewLine2\n"
NewLine1
NewLine2
                         <-- Note 2nd newline here
$ echo "$(echo "NewLine1\nNewLine2\n")"
NewLine1
NewLine2
$                        <-- No second newline
Run Code Online (Sandbox Code Playgroud)

有没有什么好办法可以在"$(....)"中将新行保留在输出的末尾?我想过只是添加一个虚拟字母并删除它,但我很想知道为什么这些新线条会消失.

unix shell scripting ksh

5
推荐指数
1
解决办法
550
查看次数

标签 统计

ksh ×1

scripting ×1

shell ×1

unix ×1