Linux – Shell – Auswahlmenü

# question (has to be: PS3="...)
PS3="Please enter your choice: "
# text for options
options=("Option 1" "Option 2" "Option 3" "Quit")

select option in "${options[@]}"
do
   case $option in
      "Option 1")
         echo "You chosed Option 1."
         echo "Do something..."
         ;;
      "Option 2")
         echo "You chosed Option 2."
         echo "Do something..."
         ;;
      "Option 3")
         echo "You chosed Option 3."
         echo "Do something..."
         ;;
      "Quit")
         echo "You chose to quit."
         break
         ;;
      *)
         echo "Invalid option"
         ;;
   esac
done

 
Weiterlesen