条件判断语句if

一、简单if语句的格式

if 条件表达式
 then
    语句1
    语句2
    ......
fi

二、if else语句的格式

if 条件测试
 then
    语句块1
else
    语句块2
fi

三、if elif 语句的使用

if 条件测试1
 then
    语句块1
elif 条件测试2
 then    
    语句块2
elif 条件测试3
 then
    语句块3
elif 条件测试4
 then 
    语句块4
......
else
    语句块5
fi

四、多 if 语句嵌套

if 条件测试1
 then
    if 条件测试2
     then
        语句块
    else
        语句块
    fi
else
    if 条件测试3
     then
        语句块
    else
        语句块
    fi
fi
原文地址:https://www.cnblogs.com/nufangrensheng/p/3482847.html