Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我在终端(bash)中运行它时
echo -e ."\c"
打印出来.并禁止换行。
.
当我运行以下脚本(所有代码)
echo -e ."\c" echo -e ."\c"
它打印出来..并抑制换行符。
..
当我在带有 shebang ( !#/bin/sh) 的脚本中运行它时,它会打印出来-e . -e .并抑制换行符。
!#/bin/sh
-e . -e .
为什么?我该如何防止这种情况?
编辑:我想防止-e's 打印出来,所以我的输出应该是. .
-e
. .
如果您的 shebang 行正在调用 sh,则需要提供 echo 的绝对路径。或者只是将 shebang 更改为使用 bash。
将您的脚本 shebang 更改为#!/bin/bash而不是,#!/bin/sh看看它是否有效
#!/bin/bash
#!/bin/sh