SHELL脚本学习
第一个shell脚本,if;then else fi语句。实现输入分数判断等级,简单开始。
1 #!/bin/bash
2
3 echo “Please input a number:”
4 read num
5 if [ $num -lt 60 ];then
6 echo “the grade is E”
7 else
8 if [ $num -ge 60 -a $num -lt 70 ];then
9 echo “the grade is D”
10 else
11 if [ $num -ge 70 -a $num -lt 80 ];then
12 echo “the grade is C”
13 else
14 if [ $num -ge 80 -a $num -lt 90 ];then
15 echo “the grade is B”
16 else echo “the gade is A”
17 fi
18 fi
19 fi
20 fi
~
#测试输出