#!/bin/sh
echo "It is morning? Please answer yes or no"
read timeofday
case "$timeofday" in
yes | y | Yes | YES)//正则表达式
echo "Good morning"
echo "Up bright and early this morning"
;;
[nN]*)
echo "Good Afternoon"
;;
*)
echo "Sorry,answer not recognized"
echo "Please answer yes or no"
exit 1
;;
esac
echo "It is morning? Please answer yes or no"
read timeofday
case "$timeofday" in
yes | y | Yes | YES)//正则表达式
echo "Good morning"
echo "Up bright and early this morning"
;;
[nN]*)
echo "Good Afternoon"
;;
*)
echo "Sorry,answer not recognized"
echo "Please answer yes or no"
exit 1
;;
esac
exit 0
为了让case的匹配功能更强大,我们可以用如下的模式:
[yY] | [Yy][Ee][Ss])