#!/bin/bash
>/tmp/top.txt
while true
do
# 生成一个100以内的随机数
ran=`echo $((RANDOM%100+1))`
if [ `grep -w $ran /tmp/top.txt|wc -l` -eq 1 ];then
continue
fi
read -p "请输入您的姓名拼音:" name
if [ $name = wolo ];then
ran_wolo=`echo $[RANDOM%10+90]`
echo -e "$name\t$ran_wolo"|tee -a /tmp/top.txt
continue
elif [ $name = liyan ];then
ran_liyan=`echo $[RANDOM%10+1]`
echo -e "$name\t$ran_liyan"|tee -a /tmp/top.txt
continue
elif [ $name = ok ];then
break
fi
echo -e "$name\t$ran"|tee -a /tmp/top.txt
done
echo "抓阄结果如下:"
head /tmp/top.txt|sort -rnk2