mardi 8 juin 2021

Create variable within a range of numbers except a list of numbers

I have the following variable with a list of numbers

vlist="1 13 20 21 22 24 25 28 240 131 133 136 138 224"

In the next loop I want to input a number between 1 - 250 except the numbers in vlist

while :; do
echo -en 'Number : ' ; read -n3 cvip ; echo
    [[ $cvip =~ ^[0-9]+$ ]] || { echo -e '\nSorry input a number between 1 and 239 except '$vlist'\n' ; continue; }
    cvip=$(expr ${cvip} + 0)
    if ((cvip >= 1 && cvip <= 250)); then break ; else echo -e '\nNumber out of Range, input a number between 1 and 239 except '$vlist'\n' ; fi
done

Ηow can I enter the list exception inside the if statement range

Aucun commentaire:

Enregistrer un commentaire