Skip to content

Instantly share code, notes, and snippets.

@yijia2413
Created May 9, 2019 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yijia2413/0b7cb8ddcbf6fd2a84b887b32c265435 to your computer and use it in GitHub Desktop.
Save yijia2413/0b7cb8ddcbf6fd2a84b887b32c265435 to your computer and use it in GitHub Desktop.
shell options
# 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