2,163
社区成员
发帖
与我相关
我的任务
分享
# !/bin/bash
echo "Please input 'Yes' or 'No' to display greetings:"
read timeofday
if [ "$timeofday" = "Yes" ]; then #[]左方括号的右边要有空格,右方括号的左边也要有空格
echo "Good Morning!"
elif [ "$timeofday" = "No" ]; then #并且then要和if放在一行,那么then前面必须要有分号这是两条语句
echo "Good afternoon!"
else
echo "Error Time!"
fi
#!/bin/sh
echo "Please input 'Yes' or 'No' to display greetings:"
read timeofday
if [ "$timeofday" == "Yes" ] ; then
echo "Good Morning!"
elif [ "$timeofday" == "No" ] ; then
echo "Good afternoon!"
else
echo "Error Time!"
fi