bash“ <<<”在一行上打印多行变量

时间:2020-07-09 12:16:31

标签: bash

为什么<<<$x删除换行符?

> cat <<<"A
B" # prints two lines (as expected)
A
B

> x="A
B"
> cat <<<"$x" # prints two lines (again, as expected)
A
B

> cat <<<$x # prints one line (..Why only one line!? I would expected two lines, or just "A", or error; Who's eating up the new line?)
A B

新行为何消失?方便<<<专用吗? 还有其他情况发生类似的事情吗? (除<<<$var之外)

此处与新行无关:https://www.tldp.org/LDP/abs/html/x17837.html (如果相关:GNU bash,版本4.2.46(2)-发行版)

0 个答案:

没有答案