linux 中 printf函数常用选项设置占位长度、左对齐、输出百分号
001、设置占位长度
[root@pc1 test1]# printf "%s\n" "abc" ## 一般输出 abc [root@pc1 test1]# printf "%20s\n" "abc" ## 设置占位长度20,默认情况下是右对齐 abc [root@pc1 test1]# printf "%-20s\n" "abc" ## 设置占位长度20,并且利用-设置为左对齐 abc [root@pc1 test1]# printf "%-20s\n" "abc" | cat -A ## 查看隐藏的占位长度 abc $
002、 输出百分号
[root@pc1 test1]# printf "%%\n" ## 输出百分号,需要用两个连续的% %
。
分类:
linux shell
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2023-02-27 centos7中 /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
2023-02-27 Error downloading packages: glibc-2.17-326.el7_9.i686: [Errno 5]
2023-02-27 win10 中tassel5安装后字体特别小的解决方法
2023-02-27 centos 7中 出现 bash: pip: command not found...解决方法
2023-02-27 SyntaxError: Non-ASCII character '\xe8' in file test.py on line 6,
2022-02-27 could not find function "get_geo_position"