shellScript之if_elif_else语句

#!/bin/bash
echo "Please input the score between(0-100):"
read score
if [ "$score" -ge 90 ];then
    echo "The grade is A ~"
elif [ "$score" -ge 80 ];then
    echo "The grade is B~"
elif [ "$score" -ge 70 ];then
    echo "The grade is C ~"
elif [ "$score" -ge 60 ];then
    echo "The grade is D ~"
else
    echo "The grade is E~"
fi



结果:

~/Note/test # ./3if_elif_else.sh 
Please input the score between(0-100):
90
The grade is A ~
~/Note/test # ./3if_elif_else.sh 
Please input the score between(0-100):
80
The grade is B~
~/Note/test # ./3if_elif_else.sh 
Please input the score between(0-100):
70
The grade is C ~
~/Note/test # ./3if_elif_else.sh 
Please input the score between(0-100):
60
The grade is D ~
~/Note/test # ./3if_elif_else.sh 
Please input the score between(0-100):
50
The grade is E


你可能感兴趣的:(shellscript)