Reputation: 1
I'm a newbie to shell scripting and a beginner in programming. I have a scenario here that i would like to ask. I had part of the script pasted below, it is part of a case switch.
echo -n "Delete Source File After Encryption : [Y|N] "
read DSFE
if [ $DSFE = "Y" -o $DSFE = "y" ]; then
Do something;
clear
elif [ $DSFE = "N" -o $DSFE = "n" ]; then
Do something;
clear
I like to find out how I can code the above snippet so that if the user input is not Y or N, it will loop and prompt the question.
Any comment on this mattter?
Thank you.
Regards, Kevin
Upvotes: 0
Views: 445
Reputation: 45526
until [[ $DSFE == [YyNn] ]]; do
read -p "Delete Source File After Encryption? [Y|N] " DSFE
done
case $DSFE in
[Yy]) do_something ;;
[Nn]) do_something_else ;;
*) # this code should not be reached
esac
Upvotes: 1