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" ## 输出百分号,需要用两个连续的% %
。
标签:百分号,test1,abc,pc1,##,linux,占位,printf From: https://www.cnblogs.com/liujiaxin2018/p/18036281