我对Bash脚本非常陌生,所以如果问题有点不一致,请原谅。
如果用户回答否,我希望我的脚本重复一个问题4次,如果用户回答是,那么脚本可以退出,这是我到目前为止的内容
#!/bin/bash
echo "Would you like a cup of tea?"
read answer
while true;
do
if [ $answer = Y ] then
echo "Great, I'll make tea now"; then
break
if [ $answer = N ] then
echo "Are you sure?"
continue
if [ $answer = N ] then
echo "Are you sure?"
continue
if [ $answer = N ] then
echo "Are you sure?"
continue
if [ $answer = N ] then
echo "Ok, I give up!"
exit
fi
梦里花落0921