shell-----简单抽奖shell脚本

#!/bin/bash
a=0
b=0
c=0
for ((i=1;i<=100;i++))
 do
luck=$(expr $RANDOM % 3)
    case $luck in
    0)
 #     echo "MR.zhang"
      let a++
      ;;
    1)
 #     echo "MR.li"
      let b++
      ;;
    2)
#       echo "MR.wang"
       let c++
       ;;
    *)
     exit 0
  esac
  done
echo ""MR.zhang:" $a "次" 、"MR.li:"$b "次"、"MR.wang:"$c 次 "




until语句与case的混合
#!/bin/bash
a=0
b=0
c=0
i=1
until [ $i -gt 10 ]
 do
    luck=$(expr $RANDOM % 3)
   let i++
     case $luck in
     0)
     echo "zhangsan"
      let a++
      ;;
      1)
     echo "lisi"
      let b++
      ;;
      2)
     echo "wangwu"
     let c++
     ;;
     *)
      exit 0
esac
done
echo "zhangsan $a次,lisi $b次,wangwu $c次"
~                                                 

 

你可能感兴趣的:(shell)