case选择结构练习
#!/bin/basn
read -p "清输入A/B/C/D四个等级" p
case $p in
'A')
echo "优秀"
;;
'B')
echo "良好"
;;
'C')
echo "中等"
;;
'D')
echo "不及格"
;;
esac
if语句练习
#!/bin/bash
echo -n "输入要删除的文件名:"
read filename
if [ -e $filename ]
then
read -p "你确定要删除吗(y/n):" p
if [ $p == 'y' ]
then `rm -f $filename`
fi
else
echo "你输入的文件不存在"
fi
while和unitl练习
#!/bin/bash
i=1
s=0
m=$#
while [ $i -le $m ]
do
a=$1
((s+=a))
shift 1;
((i++))
done
echo $s
#!/bin/bash
i=1
s=0
until [ $i -eq 11 ]
do
read -p "请输入第$i个数字:" p
((s+=p))
((i++))
done
echo $s;