Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1725002
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类:

2009-10-29 16:02:31

#!/bin/sh
echo "Is it morning? Please answer yes or no"
read timeofday

if [ "$timeofday" = "yes" ]
then
echo "Good morning"
elif ["$timeofday" = "no" ]
then
echo "Good afternoon"
else
echo "Sorry,$timeofday not recognired.Enter yes or no"
exit 1
fi

exit 0
阅读(817) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

zhengsenlin8882009-11-10 16:37:52

你的shell脚本也可以啊。 [root@localhost ~]# vi a.sh #!/bin/sh echo "is it morning? please answer yes or no." read action case $action in yes)echo "good morning";; no)echo "good afternoon";; esac [root@localhost ~]# chmod 777 a.sh [root@localhost ~]# ./a.sh is it morning? please answer yes or no. yes good morning [root@localhost ~]# ./a.sh is it morning? please answer yes or no. no good afternoon [root@localhost ~]#

chinaunix网友2009-11-07 17:08:05

我试了试 好像不行 下面是我编的 用的是case没你的考虑周全 #!/bin/sh echo "is it morning? please answer yes or no." read action case $action in yes)echo "good morning";; no)echo "good afternoon";; esac