I am trying to implement a simple menu using the select
command. The script (for testing purposes) is as follows:
#!/bin/bash
echo "*******************"
PS3='Select an option and press Enter: '
options=("apache" "named" "sendmail")
select opt in "${options[@]}"
do
case $opt in
"apache")
date
;;
"named")
echo "test"
;;
"sendmail")
echo "test 2"
;;
*) echo "invalid option";;
esac
done
echo "*********************"
The script is not recognizing any valid inputs I give and always prints the "invalid option" message. What am doing wrong in this script?