#!/bin/bash
flag=true
for i in {1..3};do
echo "第$i机会..."
read -p "请输入数字:" num
if test $num -lt 100 ;then
echo "数字太小"
elif [ $num -gt 100 ];then
echo "数字太大了"
else
echo "猜对了"
flag=false
break
fi
done
if $flag ;then
echo "3次机会用完"
fi