当前位置: 技术问答>linux和unix
关于shell实现。。求解
来源: 互联网 发布时间:2016-11-22
本文导语: 程序如下 #!/bin/sh echo -n "是否正确: " read yesno case $yesno in "y" | "Y") echo yes ;; "n" | "N") echo no ;; *) echo "输入错误,重新输入" ;; esac 怎么样实现,如果用户输入的不是 y Y n N这4个值 就在此跳回到上面让用户...
程序如下
怎么样实现,如果用户输入的不是 y Y n N这4个值
就在此跳回到上面让用户输入,然后执行。。。、
直到输入正确位置???
#!/bin/sh
echo -n "是否正确: "
read yesno
case $yesno in
"y" | "Y")
echo yes
;;
"n" | "N")
echo no
;;
*)
echo "输入错误,重新输入"
;;
esac
怎么样实现,如果用户输入的不是 y Y n N这4个值
就在此跳回到上面让用户输入,然后执行。。。、
直到输入正确位置???
|
#!/bin/sh
yesno="dfsa"
while [ "$yesno" != "Y" ] && [ "$yesno" != "y" ] && [ "$yesno" != "N" ] && [ "$yesno" != "n" ]; do
echo -n "是否正确: "
read yesno
case $yesno in
"y" | "Y")
echo yes
;;
"n" | "N")
echo no
;;
*)
echo "输入错误,重新输入"
;;
esac
done
|
read yesno
while [ $yesno != "Y" ] && [ $yesno != "y" ] && [ $yesno != "n" ] && [ $yesno != "N" ];
do
echo "输入错误,重新输入"
read yesno
done
case $yesno in
"Y" | "y" )
echo yes
;;
"n" | "N" )
echo no
;;
* )
echo "输入错误,重新输入"
esac
|
while true
do
echo -n "是否正确: "
read yesno
case $yesno in
"y" | "Y")
echo yes
break
;;
"n" | "N")
echo no
break
;;
*)
echo "输入错误,重新输入"
;;
esac
done
do
echo -n "是否正确: "
read yesno
case $yesno in
"y" | "Y")
echo yes
break
;;
"n" | "N")
echo no
break
;;
*)
echo "输入错误,重新输入"
;;
esac
done