```#!/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