比较的基本原理
if [ "$FILE"="aaa" ]
then
echo "something1"
else
echo "something2"
fi
左方括号"["是shell的一个内部命令
和test命令类似
if test "$FILE"="aaa"
then ...
test "$FILE"="aaa" && echo "they are eq"
[ "$FILE"="aaa" ] && {
echo "en eq"
}
性能上无差别
test "$FILE"="aaa" || echo "they are eq"
右括号表示比较完成,根据命令返回码比较是否为真
执行命令作为条件
if [ "`grep nodename /etc/hosts`" ];then ...