LoginSignup
0
0

More than 1 year has passed since last update.

if user input number (bash)

Posted at
if_input_number.sh
    read -n 1 -p "Would you like to install 
                1. AAAA
                2. BBBB
                3. CCCC
                4. DDDD 
                
                Please select (1/2/3/4) " ans;

    echo " "
    case $ans in
        1)
            echo "install AAAA";;
        2)
            echo "install BBBB";;
        3)
            echo "install CCCC";;
        4)
            echo "install DDDD";;
        *)
            echo "Unknown"
            exit;;
    esac

result

hoshina@hoshina-ThinkPad-X1-Carbon-7th:~$ bash if_input_number.sh 
Would you like to install 
                1. AAAA
                2. BBBB
                3. CCCC
                4. DDDD 
                
                Please select (1/2/3/4) 2 
install BBBB

Screenshot from 2022-06-28 10-53-07.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0