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