1. 程式人生 > >LINUX中printf與echo的區別

LINUX中printf與echo的區別

(1)首先echo是回顯,即代表回車顯示,是自帶換行的;而printf只是打印出來,沒有換行
(2)echo只是回顯沒有變數替換功能;printf是有的
舉例:假如我們定義好變數a='hello world'
則 echo "%s" $a  顯示的結果就是%s
而 printf "%s\n" $a  顯示的結果就是hello world