成都创新互联网站制作重庆分公司

shell脚本如何实现echo输出不换行功能-创新互联

这篇文章主要为大家展示了“shell脚本如何实现echo输出不换行功能”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“shell脚本如何实现echo输出不换行功能”这篇文章吧。

创新互联科技有限公司专业互联网基础服务商,为您提供联通机房服务器托管高防服务器,成都IDC机房托管,成都主机托管等互联网服务。

There are as many ways to solve this quirky echo problem as there are pages in this book. One of my favorites is very succinct:

function echon
{
 echo "$*" | awk '{ printf "%s" $0 }'
}

You may prefer to avoid the overhead incurred when calling the awk command, however, and if you have a user-level command called printf you can use it instead:

echon()
{
 printf "%s" "$*"
}

But what if you don't have printf and you don't want to call awk? Then use the tr command:

echon()
{
 echo "$*" | tr -d '\n'
}

This method of simply chopping out the carriage return with tr is a simple and efficient solution that should be quite portable.


以上是“shell脚本如何实现echo输出不换行功能”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


网站题目:shell脚本如何实现echo输出不换行功能-创新互联
分享URL:http://cxhlcq.com/article/ggddc.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部