bash中的“:”是什么?冒号作为pass语句的用法
见: 这叫什么:冒号用法?例如:bash中的“:”是什么?冒号作为pass语句的用法,bash,Bash,见: 这叫什么:冒号用法?例如: if [[ -n $STRING ]]; then #printf "[INFO]:STRING: if -n string: STRING:$STRING \n" : else printf "[INFO]:Nothing in the the string\n" fi while :; do date; sleep 1; done 为此,请在shell中运行help:in。它给出: 在单线性无限循环中非常有用,例如: if [[
if [[ -n $STRING ]]; then
#printf "[INFO]:STRING: if -n string: STRING:$STRING \n"
:
else
printf "[INFO]:Nothing in the the string\n"
fi
while :; do date; sleep 1; done
为此,请在shell中运行help:in。它给出:
在单线性无限循环中非常有用,例如:
if [[ -n $STRING ]]; then
#printf "[INFO]:STRING: if -n string: STRING:$STRING \n"
:
else
printf "[INFO]:Nothing in the the string\n"
fi
while :; do date; sleep 1; done
同样,你也可以用true而不是:,来写同样的东西,但是这个要短一些
有趣的是:
根据这一点,区别在于:是Null命令,
而true则返回一个成功的结果。
另一个区别是true通常是实二进制:
另一方面,它什么也不给。这是有道理的,作为一个空命令
无论如何,这是对的,这是重复的,这解释得更好
$ which true
/usr/bin/true