#!/bin/bash str=wgw for ((i=1;i<=3;i++)) do read -p "請輸入密碼: " nb if [ ${nb}a = ${str}a ];then echo "密碼輸入正確" break else echo "密碼輸入錯誤。第$i次機會" fi done