题目:
反向输出
- 当用户输入yes,显示no
- 当用户输入no,显示yes
- 当用户输入其它,提示用户输入yes/no
- 忽略大小写
脚本:
#!/bin/bash
#This is a shell script for input yes to no
read -p "Please enter your choose: " choose
if [ $choose == yes ] || [ $choose == YES ]
then
echo "no"
elif [ $choose == no ] || [ $choose == NO ]
then
echo "yes"
else
echo "You input error,please input yes or no"
fi
解答:
三种情况,yes/no/未知字符,使用If语句,并嵌套判断条件,yes||YES