我目前創建了一個unix bash,要求輸入Y/N,然後爲用戶輸入y或n時創建了代碼。但是如果用戶鍵入其他的東西,它會出現「請輸入Y或N」的回聲,那麼我如何重定向它以便返回到原始的Y/N輸入?Unix - 針對Y/N回答問題
#! /bin/bash
echo "Do you want to change the directory? Y/N?"
read answer
if [[ $answer == "y" || $answer == "Y" ]]; then
echo "Yes"
elif [[ $answer == "n" || $answer == "N" ]]; then
echo "No"
else
echo "Please enter Y or N"
#redirect back to "Do you want to change the directory" echo
fi
哪裏是你當前的代碼? – 2014-12-07 13:04:33
剛剛添加的代碼 – james111 2014-12-07 13:10:51