One of the hardest parts of my project was keeping the project from 'bombing' when someone entered a letter(s) or just hit enter when the menu called for a number. Myscript does a good job of this using the 'case select in' routine. I thought I would pass on an alternative. I used it as the basis for most of the menues in my project.
#!/bin/bash
# An alternative menu
# Ollie Wright 12/10/08
a=0
while [ "$a" -lt 9 ];
do
echo -n "enter something or 9 to quit "
read a
if [[ -z $(echo $a | grep "^[0-9]*$") ]] # I did not think of this myself!
then
echo "$a is a not a number "
a=0 # reset a to keep loop running
else
echo "$a is is a number " # this is where to put whatever action to take
fi
done