我正在编写一个 bash 脚本,我想回显一个字符串,但没有自动添加到末尾的换行符。阅读手册页,它说标志是-n.
问题是,当我这样做时:
echo -n "My string is here"
Run Code Online (Sandbox Code Playgroud)
bash 脚本中的输出是:
-n My string is here
Run Code Online (Sandbox Code Playgroud)
知道为什么-n输出标志而不是处理标志。
检查您正在使用的外壳:
echo $0
Run Code Online (Sandbox Code Playgroud)
如果是/bin/sh,请更改为/bin/bashwithchsh并重试。
http://hints.macworld.com/article.php?story=20071106192548833
| 归档时间: |
|
| 查看次数: |
6031 次 |
| 最近记录: |