python、bash猜数字游戏,pythonbash猜数字,#!/bin/bashN
文章由Byrx.net分享于2019-03-23 05:03:35
python、bash猜数字游戏,pythonbash猜数字,#!/bin/bashN
#!/bin/bashNUM=`echo $RANDOM$RANDOM |cut -c 2-3`DATE=`date +%y%m%d-%H:%M`read -p "Please input your name: " USERi=1while truedo read -p "Please input a "double-digit": " input case $input in [0-9][0-9] ) if [ $input -gt $NUM ] ;then echo "Try smaller!" elif [ $input -lt $NUM ];then echo "Try bigger!" else echo "Good! You are right!" break; fi ;; *) echo "The number should be in 1 to 100: " ;; esaci=$((i+1))doneprintf "%-12s %s\n" "<$USER>" "your record is $i! Try better next time! $DATE" |tee -a ./record.recordprintf "\n\n"printf "%15s %6s %-8s\n" "-----" "HISTORY RECORD" "-----"cat ./record.record |sort -k5 -g|awk -F! '{print $1,"!",$3}'|head -10printf "%15s %6s %-8s\n" "-----" "HISTORY RECORD" "-----"
评论关闭