源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Linux shell中的printf的详细用法

  • 时间:2021-12-05 15:24 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Linux shell中的printf的详细用法
[b]Linux shell中的printf的详细用法[/b] [b]一 语法[/b] printf '输出类型输出格式' 输出内容 输出类型: %ns:输出字符串。n是数字指代输出几个字符。 %ni:输出整数。n是数字指代输出几个数字。 %m.n:输出浮点数。m和n是数字,指代输出的整数位数和小数 如%8.2代表共输出8位数,其中2位是小数,6位是整数。 输出格式: [img]http://files.jb51.net/file_images/article/201709/201799141120270.png?201789141135[/img] [b] 二 实战[/b]
[root@localhost ~]# printf %s 1 2 3 4 5 6
123456[root@localhost ~]# printf %s %s %s 1 2 3 4 5 6
%s%s123456[root@localhost ~]# printf '%s %s %s' 1 2 3 4 5 6
1 2 34 5 6[root@localhost ~]# printf '%s\t%s\t%s\n' 1 2 3 4 5 6
1 2 3
4 5 6
[root@localhost ~]# printf '%s' $(cat student.txt)
1furongF852fengjF603cangF70[root@localhost ~]#
[root@localhost ~]# printf '%s\t%s\t%s\t%s\n' $(cat student.txt)
1 furong F 85
2 fengj F 60
3 cang F 70

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部