printf和print
$ df -h | grep "/dev/sd.." | awk '{print $5}'?
12%?
1%?
$ df -h | grep "/dev/sd.." | awk '{printf $5"\n"}'?
awk: run time error: not enough arguments passed to printf("12% ") FILENAME="-" FNR=1 NR=1
?哪里錯(cuò)了? 不是一樣嗎
$ df -h | grep "/dev/sd.." | awk '{print $5}'?
12%?
1%?
$ df -h | grep "/dev/sd.." | awk '{printf $5"\n"}'?
awk: run time error: not enough arguments passed to printf("12% ") FILENAME="-" FNR=1 NR=1
?哪里錯(cuò)了? 不是一樣嗎
2016-04-24
舉報(bào)
2020-09-03
因?yàn)槟愕慕Y(jié)果是21%,但是printf? "21%"會(huì)報(bào)錯(cuò),要想用printf輸出'%',需要printf? '%%',所以改為$ df -h | grep "/dev/sd.." | awk '{printf $5"%""\n"}'就ok了?
2016-05-25
我的為什么行啊?
2016-04-24
printf 是格式化輸出,需要制定輸出格式