I'm trying to write a bash script which asks the user to select two options. If the user selects the option within the scope of available options, then script goes fine. But if the user enters an invalid option, I can only exit the script echoing user that the option is invalid. Can i write the script in such a way that if user enters invalid option, the script should re-prompt the user to provide correct option again..
Here is what the script looks like.
echo "Please select the correct option."
echo "Valid options are 0 and 1"
if [ $userinput -eq 0 ]
# do this
elif [ $userinput -eq 1 ]
# do this.
# needs to be replaced to start from "read userinput" again.