Created
May 9, 2019 09:50
-
-
Save yijia2413/0b7cb8ddcbf6fd2a84b887b32c265435 to your computer and use it in GitHub Desktop.
shell options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy from https://coolshell.cn/articles/8619.html | |
#!/bin/bash | |
# Bash Menu Script Example | |
PS3='Please enter your choice: ' | |
options=("Option 1" "Option 2" "Option 3" "Quit") | |
select opt in "${options[@]}" | |
do | |
case $opt in | |
"Option 1") | |
echo "you chose choice 1" | |
;; | |
"Option 2") | |
echo "you chose choice 2" | |
;; | |
"Option 3") | |
echo "you chose choice $REPLY which is $opt" | |
;; | |
"Quit") | |
break | |
;; | |
*) echo "invalid option $REPLY";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment