Skip to main content
3 of 4
added 373 characters in body
Azalix
  • 13
  • 1
  • 4

Bash script question - skip enter key press

Here is a portion of my script:

read main_menu

case "$main_menu" in

    "0" )   exit
            ;;
    "1" )   cp /etc/bamt/cgminer.conf.X11 /etc/bamt/cgminer.conf;
            sudo mine restart;
            ;;

How can I make it so after the user enters 0 or 1, 2 etc, he doesn't have to press the Enter key? Practically, when you enter the number it would directly jump to the next menu or function without the needing to press Enter.

Can you help me implement it here?

while :
do
    echo -e "\n Test script"
    echo -e "\t (0) Exit"
    echo -e "\t (1) Option 1"
    echo -n "Enter choice:"
      read main_menu
      case "$main_menu" in
         "0" ) exit
         ;;
         "1" ) exit
         ;;
esac
done

Thanks again!

Azalix
  • 13
  • 1
  • 4