html tool

2022年10月13日星期四

转:bash中printf与echo的区别

 地址:https://blog.csdn.net/drbing/article/details/52905564

(1)首先echo是回显,即代表回车显示,是自带换行的;而printf只是打印出来,没有换行

(2)echo只是回显没有变量替换功能;printf是有的

举例:假如我们定义好变量a='hello world'

则 echo "%s" $a  显示的结果就是%s

而 printf "%s\n" $a  显示的结果就是hello world


没有评论:

发表评论