1.touch /home/price.sh
2.vim /home/price.sh
#!/bin/bash
#猜价格游戏
i=10;
jiage=`expr $RANDOM % $i`;
time=0;
echo "商品实际价格在0-9之间,猜猜看是多少?";
while true
do
read -p "请输入你猜的价格数目:" INT
let time++
if [ $INT -eq $jiage ] ;then
echo "恭喜你答对了,实际价格是 $jiage"
echo "你总共猜测了$time 次"
exit0
elif [ $INT % $jiage ] ;then
echo "太高了!"
else
echo "太低了!"
fi
done
3. chmod u+x /home/price.sh
4. /home/price.sh
阅读(927) | 评论(0) | 转发(0) |