shell 中键盘输入
命令read
测试test.sh
#!/bin/bash
read -p "Please input number:" num
if [ "$num" -eq "1" ]; then
echo -e "\033[32mYou enter the number is 1\033[0m"
elif [ "$num" -eq "2" ];then
echo -e "\033[33mYou enter the number is 2\033[0m"
elif [ "$num" -eq "3" ];then
echo -e "\033[31mYou enter the number is 3\033[0m"
elif [ "$num" -eq "4" ];then
echo -e "\033[34mYou enter the number is 4\033[0m"
fi
转载于:https://blog.51cto.com/520and519/1558360