Programming Tips - bash: How can I do a simple menu in bash?

Date: 2012sep16 Language: Bash OS: Linux Q. bash: How can I do a simple menu in bash? A. Put the read command into a while loop like this:
# Use echo to display the choices... echo echo "Select program to run" echo echo " 1. Program One" echo " 2. Program Two" echo " 3. Program Three" echo -n "> " # Loop until the user enters something valid... while :; do # Read one character and don't echo it... read -s -n 1 c if [[ $c == 1 ]]; then echo $c # Run program one break fi if [[ $c == 2 ]]; then echo $c # Run program two break fi if [[ $c == 3 ]]; then echo $c # Run program three break fi done