读书笔记之101个脚本之No.8
2011-06-21 23:51
417 查看
这是第8/101个脚本
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:
But what if you don't have printf and you don't want to call awk? Then use the tr command:
This method of simply chopping out the carriage return with tr is a simple and efficient solution that should be quite portable.
这个脚本很简单,就是可以用3种不同的函数(方法)来实现,输出后不换行。
The Code
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.
这个脚本很简单,就是可以用3种不同的函数(方法)来实现,输出后不换行。
相关文章推荐
- 读书笔记之101个脚本之No.7
- 读书笔记之101个脚本之No.4
- 读书笔记--101个shell脚本 之#10
- 读书笔记之101个超酷脚本之001
- 读书笔记--101个shell脚本 之#12--函数
- 读书笔记--101个shell脚本 之#11--炫
- 读书笔记--101个shell脚本--05
- 读书笔记--101个shell脚本 之#13--猜数字
- 读书笔记--101个shell脚本 之#9
- 自动化测试脚本语言-Python 读书笔记
- 《高性能javascript》读书笔记--js脚本的加载与执行
- linux shell 脚本攻略 读书笔记chaper1
- 【打发时间之US脚本】读书笔记4
- 101个脚本之linux回收站
- 读书笔记:《java脚本编程:语言、框架与模式》-(1)脚本语言
- 101个脚本之建立linux回收站的脚本
- 【高性能JavaScript】读书笔记 - 引入脚本(二) - 02
- Linux Shell脚本攻略 读书笔记
- Oracle性能诊断艺术-读书笔记(脚本execution_plans截图)
- Shell 脚本学习指南读书笔记(长期更新)