hi
i want to make script. where i want to query from the user yes or no
exp: do you want to proceed :
y for yes
n for NO.
how this is possible in unix
hi
i want to make script. where i want to query from the user yes or no
exp: do you want to proceed :
y for yes
n for NO.
how this is possible in unix
something like:
#!/bin/bash
read -p "Do you want to proceed [YES/NO] : " K
case $K in
yes|YES) echo "you answered YES"; exit 0 ;;
no|NO) echo "you answered NO"; exit 1 ;;
*) echo "You must answer YES or NO"; exit 2 ;;
esac
The script can be called like:
if script
then
do something
fi
it gives some error:
Do you want to proceed [YES/NO] :
yes
you answered YES
test_test.sh: cannot return when not in function
i want to take some action on yes also.
Oops not return but exit
I'll correct the original post