How to have spaces or tabs in the menu list?
PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Option 1")
echo "Your choise is 1"
;;
"Option 2")
echo "Your choise is 2"
;;
"Quit")
break
;;
*) echo "Invalid option;;
esac
done
And I got this:
[user@Server:/home/user] ./test.sh
1) Option 1
2) Option 2
3) Option 3
4) Quit
Please enter your choice:
But I'd like something like this:
[user@Server:/home/user] ./test.sh
1) Option 1
2) Option 2
3) Option 3
4) Quit
Please enter your choice:
Ideas?
casestatement. It's theselectthat displays the menu. As an aside note: If you usecase $REPLY in, you can test on the numbers instead. That way you don't have to repeat all those strings.