Artificial intelligent assistant

Linux - case command 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?

The `select` statement in `bash`, which is what displays the menu, does not allow specifying an indent for the menu.

* * *

Just a comment on the code: It's usually easier to let the `case` statement act on `$REPLY` rather than the variable with the selected string. It saves you from having to type in the strings twice.

E.g.


select opt in "${options[@]}"
do
case $REPLY in
1)
echo "Your choice is 1"
;;
2)
echo "Your choice is 2"
;;
3)
break
;;
*) echo 'Invalid option' >&2
esac
done


or, for this specific example,


select opt in "${options[@]}"
do
case $REPLY in
[1-2])
printf 'Your choice is %s\
' "$REPLY"
;;
3)
break
;;
*) echo 'Invalid option' >&2
esac
done

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy b7fbc0366ee7ee8db8e5d4f13fa58071