echo 能回显多行内容吗?

希望
echo "abc\ndef"能显示成
abc
def

但是echo好像不支持转义字符?
---------------------------------------------------------------

echo -e "abc\ndef" 如何?

echo的参数 -e 就是为转义字符设置的 :)

另外,不同的SHELL在这里差别比较大。
有的SHELL根本就不需要什么 -e ,直接 echo "abc\ndef" 就工作的很好,而有的需要。
---------------------------------------------------------------

echo -e "1234\n3456"
---------------------------------------------------------------

linux shell 是要用 -e 来打开转义功能的。

Published At
Categories with 服务器类
comments powered by Disqus