格式化输出和printf命令

GNU版本的printf命令用来格式化输出,效果类似与C语言的printf函数。
2.x以上版本的Bash内建的printf命令和e/usr/bin下的printf命令使用方法一样。

例子:
$printf "The number is %.2f\n" 100
The number is 100.00

$printf "%-20s%-15s%10.2f\n" "Jody" "Savage" 28 //%-20s表示左对齐
Jody Saveage 28.00

$printf "\x61%s" bort
abort 

=-=-=-=-=
Powered by Blogilo

posted on 2015-08-02 11:53  chenxiaopang  阅读(141)  评论(0编辑  收藏  举报

导航