#!/bin/bash
pc=$(expr $RANDOM % 1000 + 1)
echo "$pc" >> /tmp/123 bug 保存到一个目录下查看答案
cishu=0
echo "这是猜商品的价格的小游戏,价格范围(1-1000)"
while true
do
read -p "请输入你猜测的价格:" jiage
let cishu++
if [ $jiage -eq $pc ]
then
echo "恭喜你猜对了,价格就是$jiage "
echo "共猜了$cishu "
exit 0
elif [ $jiage -gt $pc ]
then
echo "猜高了"
else
echo "猜低了"
fi
done
~