shell问题!求教!
#!/bin/sh
echo "Is morning ? Please answer yes or no"
read timeof
echo $timeof
if [ "$timeof"="no" ];then
echo "Good morning"
elif [ "$timeof"="yes" ];then
echo "Good afternoon"
else
echo "Sorry, $timeof is not rencognized. Enter yes or no"
exit 1
fi
exit 0
为什么不管怎么输入都显示输出Good morning 哪里错啦?
[解决办法]
= 两边留个空格
[解决办法]
主要是判断语句里面的等号两边漏下空格了。
- JScript code
#!/bin/shecho "Is morning ? Please answer yes or no"read timeofif [ $timeof = "yes" ];then echo "Good morning"elif [ $timeof = "no" ];then echo "Good afternoon"else echo "Sorry, $timeof is not rencognized. Enter yes or no"fi