冒号是bash shell中一个内建命令,有多种用法
1、空命令,返回永真
就是什么也不做,所以返回码永远都是0。
(1)用于循环条件中表示永真
#!/bin/bash
i=0
while :
do
if ((i >= 10))
then
break
fi
echo $((++i))
done
(2)充当空语句,占位符,作用类似于Python中的pass
if [ "today" == "2011-08-29" ]; then
:
else
:
fi
2、与重定向结合,清空一个文件:
[root@localhost /home/eddy]#cat log
test
[root@localhost /home/eddy]#:>log
[root@localhost /home/eddy]#cat log
3、参数扩展
参数扩展的概念参照:
https://blog.csdn.net/astrotycoon/article/details/78109827
4、用于注释中,特别是多行注释
: << EOF
This is
multiline comment.
EOF
echo test