首页 > 代码库 > "中奖"

"中奖"

ls name.txt &>/dev/null && name=($(cat name.txt))|| name=($(cat list.txt))
echo -ne "名单共有${#name[@]}位成员:"
for i in $(seq 0 ${#name[@]})
do
       echo -ne " ${name[$i]}"
done
second=3
echo -en "\n***倒计时$second秒开始***\t\t"
for i in $(seq $second -1 1)
do
       echo -ne "\033[1;31m\b\b\b $i \033[0m"
       sleep 1
done
choice=$((RANDOM%${#name[@]}))
echo "这次选出的成员是:${name[$choice]}"
unset name[$choice]
((${#name[@]}==0)) && rm -rf name.txt ||echo ${name[@]} >name.txt

本文出自 “爱武装一辈子” 博客,请务必保留此出处http://menglinux.blog.51cto.com/8733806/1436444