这篇文章主要为大家展示了“shell脚本如何实现echo输出不换行功能”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“shell脚本如何实现echo输出不换行功能”这篇文章吧。
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输出不换行功能”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。