Linux学习记录(二)----if

常用格式

格式一:

if 条件; then

    语句

fi

格式二:

if 条件; then

    语句

else

    语句

fi

格式三:

if 条件; then

    语句

elif 条件; then

    语句

fi

格式四:

if 条件; then

    语句

elif 条件; then

    语句

else

    语句

fi

使用示例

(1)判断字符串相等

if [ "foo" = "foo" ]; then
   echo expression evaluated as true
else
    echo expression evaluated as false
 fi

result  : expression evaluated as true

(2)

---------------------初次乍到,待补充------

原文地址:https://www.cnblogs.com/xinqi/p/4901687.html