Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

bash similiar to choice in cmd

#!/bin/bash  
clear

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;;
        *) 
        #handle no option value
        echo "invalid option $REPLY";;
    esac
done
Source by askubuntu.com #
 
PREVIOUS NEXT
Tagged: #bash #similiar #choice #cmd
ADD COMMENT
Topic
Name
1+8 =