抓阄
#!/bin/bash function rand(){ echo $((RANDOM%100+1)) } > /tmp/user.txt while true do clear echo "抓阄获奖名单如下: " sort -rnk2 /tmp/user.txt |head -3 read -p 'please input name: ' NAME [ -z "$NAME" ] && continue if [ "$NAME" = "q" ];then break fi if grep -w "$NAME" /tmp/user.txt &> /dev/null;then continue fi RAND=$(rand) while grep -w "$RAND" /tmp/user.txt &> /dev/null do RAND=$(rand) done echo -e "$NAME\t$RAND" >>/tmp/user.txt done echo "抓阄获奖名单如下: " sort -rnk2 /tmp/user.txt |head -3Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx