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输出不换行功能-创新互联
转载来于:http://bzwzjz.com/article/ggddc.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站制作 自适应网站建设 成都网站设计 响应式网站设计 营销型网站建设 品牌网站建设 成都网站建设流程 成都网站设计 网站建设方案 品牌网站建设 成都品牌网站建设 教育网站设计方案 成都商城网站建设 四川成都网站设计 网站建设费用 做网站设计 响应式网站设计方案 成都网站设计 网站建设推广 定制网站设计 成都网站建设 成都网站制作