Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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 3"
- ;;
- "Quit")
- break
- ;;
- *) echo invalid option;;
- esac
- done
- title="Select example"
- prompt="Pick an option:"
- options=("A" "B" "C")
- echo "$title"
- PS3="$prompt "
- select opt in "${options[@]}" "Quit"; do
- case "$REPLY" in
- 1 ) echo "You picked $opt which is option $REPLY";;
- 2 ) echo "You picked $opt which is option $REPLY";;
- 3 ) echo "You picked $opt which is option $REPLY";;
- $(( ${#options[@]}+1 )) ) echo "Goodbye!"; break;;
- *) echo "Invalid option. Try another one.";continue;;
- esac
- done
- while opt=$(zenity --title="$title" --text="$prompt" --list
- --column="Options" "${options[@]}"); do
- case "$opt" in
- "${options[0]}" ) zenity --info --text="You picked $opt, option 1";;
- "${options[1]}" ) zenity --info --text="You picked $opt, option 2";;
- "${options[2]}" ) zenity --info --text="You picked $opt, option 3";;
- *) zenity --error --text="Invalid option. Try another one.";;
- esac
- done
- sudo -s "echo get debconf/frontend | debconf-communicate"
- !#/bin/bash
- echo "select the operation ********* 1)operation 1 2)operation 2 3)operation 3 4)operation 4 "
- read n
- case $n in
- 1) commands for opn 1;;
- 2) commands for opn 2;;
- 3) commands for opn 3;;
- 4) commands fo opn 4;;
- *) invalid option;;
- esac
- #! /bin/bash
- selection=$(zenity --list "Option 1" "Option 2" "Option 3" --column="" --text="Text above column(s)" --title="My menu")
- case "$selection" in
- "Option 1")zenity --info --text="Do something here for No1";;
- "Option 2")zenity --info --text="Do something here for No2";;
- "Option 3")zenity --info --text="Do something here for No3";;
- esac
- #! /bin/bash
- selection=$(zenity --list "Option 1" "Option 2" "Option 3" --column="" --text="Text above column(s)" --title="My menu")
- case "$selection" in
- "Option 1")zenity --info --text="Do something here for No1";;
- "Option 2")zenity --info --text="Do something here for No2";;
- "Option 3")zenity --info --text="Do something here for No3";;
- esac
- ls
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement