目标能够使用if条件语句进行条件判断
1.if语法
多行写法语法
if 条件
then
命令
fi
可以将if语句放入一行语法
if 条件:then 命令:fi
if ((1==1));then echo “成立”;else echo “buchengli”;fi;
2.if else语法
if 条件
then
命令
else
命令
fi
3.if else else语法
if 条件1
then
命令1
elif 条件2
then
命令2
elif 条件3
then
命令3
else
命令n
fi
#!/bin/bash
read -p “请输入你的考试成绩;” score
if ((score<60 && score>=0))
then
echo “不及格”
elif ((score>=60 && score<70))
then
echo "及格"
elif ((score>=70 && score<80))
then
echo "中等"
elif ((score>=80 && score<90))
then
echo "良好"
elif ((score>=90&&score<=100))
then
echo “优秀”
else
echo "成绩不合符"
fi