這篇文章給大家介紹printf語(yǔ)句怎么在Linux 中使用,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
Linux shell中的printf的詳細(xì)用法
一 語(yǔ)法
printf '輸出類型輸出格式' 輸出內(nèi)容
輸出類型:
%ns:輸出字符串。n是數(shù)字指代輸出幾個(gè)字符。
%ni:輸出整數(shù)。n是數(shù)字指代輸出幾個(gè)數(shù)字。
%m.n:輸出浮點(diǎn)數(shù)。m和n是數(shù)字,指代輸出的整數(shù)位數(shù)和小數(shù)
如%8.2代表共輸出8位數(shù),其中2位是小數(shù),6位是整數(shù)。
輸出格式:
二 實(shí)戰(zhàn)
[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
關(guān)于printf語(yǔ)句怎么在Linux 中使用就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
當(dāng)前文章:printf語(yǔ)句怎么在Linux中使用-創(chuàng)新互聯(lián)
文章URL:http://chinadenli.net/article14/ehide.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、移動(dòng)網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站、動(dòng)態(tài)網(wǎng)站、小程序開(kāi)發(fā)、營(yíng)銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容