The following is part of a script I'm writing to show releases of software available in a directory and then ask the user to select one. While $answer is not in the avail[] array ask the question again. I need to know how to compare each element in the array to the answer variable in the while loop condition. Any help is greatly appreciated. Thanks
avail=(`ls -C`)
echo "Releases available: ${avail[*]}"
echo -n "What SCSRelease whould you like to run? (x.x.x) "; read answer
# This part does not work
while [ "$answer" != "${avail[*]}" ];
do
echo -n "Release is already running or not valid. Try again: (x.x.x) "
done
avail=(`ls -C`)
echo "Releases available: ${avail[*]}"
echo -n "What SCSRelease whould you like to run? (x.x.x) "; read answer
# This part does not work
while [ "$answer" != "${avail[*]}" ];
do
echo -n "Release is already running or not valid. Try again: (x.x.x) "
done