首页 > 代码库 > shell -- yes or no

shell -- yes or no

read -p "Do you want to .... [Y/N]? " yn
while true; do
    case $yn in
        [Yy]|[Yy][Ee][Ss] )
            break
            ;;
        [Nn]|[Nn][Oo] )
            echo "exiting....."
            exit
            ;;
        * ) 
            echo -n "Please type yes or no: "
            read yn
            ;;
    esac
done

 

shell -- yes or no