0514-86177077
9:00-17:00(工作日)
Linux shell中的printf的詳細用法
一 語法
printf '輸出類型輸出格式' 輸出內容
輸出類型:
%ns:輸出字符串。n是數字指代輸出幾個字符。 %ni:輸出整數。n是數字指代輸出幾個數字。 %m.n:輸出浮點數。m和n是數字,指代輸出的整數位數和小數
如%8.2代表共輸出8位數,其中2位是小數,6位是整數。
輸出格式:
二 實戰
[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
如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
標簽:烏蘭察布 臨沂 贛州 撫州 海北 廣東 昌都 連云港
上一篇:shell中各種括號的作用詳解()、(())、[]、[[]]、{}(推薦)
下一篇:shell字符截取命令之cut命令的實例詳解
Copyright ? 1999-2012 誠信 合法 規范的巨人網絡通訊始建于2005年
蘇ICP備15040257號-8