码迷,mamicode.com
首页 > 其他好文 > 详细

格式化输出和printf命令

时间:2015-08-02 13:01:54      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

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

格式化输出和printf命令

标签:

原文地址:http://www.cnblogs.com/pandachen/p/4695457.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!