Bash 如何在三次尝试后自动中断Case语句?
我正在发布我的脚本: :脚本:Bash 如何在三次尝试后自动中断Case语句?,bash,ssh,Bash,Ssh,我正在发布我的脚本: :脚本: clear echo -e '\E[44m'"Testing case conditions"; tput sgr0 until [ "$vpm" = "n" ]; do read -p "Do you want to continue (Y/n): " vpm case $vpm in "Y" | "y" | "yes" | "Yes" | "YES" | "yES" | "yeS" | "YeS" | "YEs" | "yEs") read -p "Pass
clear
echo -e '\E[44m'"Testing case conditions"; tput sgr0
until [ "$vpm" = "n" ]; do
read -p "Do you want to continue (Y/n): " vpm
case $vpm in
"Y" | "y" | "yes" | "Yes" | "YES" | "yES" | "yeS" | "YeS" | "YEs" | "yEs")
read -p "Pass your string: " sin
clear
echo -e '\E[42m'"$sin"; tput sgr0
sleep 3
;;
"n")
echo "Exit"
;;
* )
#echo "Invalid parameter" #At this line if user enter any thing else except of yes /n the script print invalid parameter but I want to break it after 3rd wrong input.**
;;
esac
done
exit 1
我想在第三次输入无效参数后退出此脚本。请告诉我这是如何实现的。为了清晰(和重用),请将“是”比较代码放入函数中
您可以对int重试执行=1到3
,如果回答了退出
/中断