Bash script - Test variable against a range
I am fairly new to bash scripting, and I am trying to test a variable against a number range (1-3).
This is what I have used so far:
The user enters a value, then
while [ "$PROV" != "1" ] && [ "$PROV" != "2" ] && [ "$PROV" != "3" ] && [ $COUNTER -lt 4 ] || [ -z "$PROV" ] && [ $COUNTER -lt 4 ]; do
clear
echo
echo "You did not enter an appropriate choice. Please enter 1, 2, or 3."
echo "1)PROV1"
echo "2)Prov2"
echo "3)Prov3"
echo
echo "Enter Choice:"
read -e PROV
echo
let COUNTER++
done
Is there a cleaner way to do this?
Something like:
while [ "$PROV" != "1-3" ]&& [ $COUNTER -lt 4 ] || [ -z "$PROV" ] && [ $COUNTER -lt 4 ]; do
Thank you.
|