bin/bash shell 换行失败

1

dash中

echo 'hello\nworld'

将会输出

hello
world

2

bash中

echo 'hello\nworld'

将会输出

hello\nworld

一般情况下 /bin/sh 被软链到 /bin/dash,偶尔也会遇到有人把 /bin/sh 软链到 /bin/bash。就会出现结果与预期不符的情况。

/bin/echo -e 'hello\nworld'

可以解决上述问题

bash支持的语法更多,建议用bash。dash更轻量级。

posted @ 2020-06-10 10:06  TBHacker  阅读(423)  评论(0编辑  收藏  举报