typeset input
#日期取得
while true
do
printf "请输入日期:"
printf ""exit"\n退出循环"
printf "[YYYY-MM-DD]==>"
read $input
if [["${input}" = "exit"]]
then
return 0
fi
if [[${input} != [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] ]]
then
printf "日期形式错误:【输入值为:${input}】"
continue
else
break
fi
done
转载于:https://blog.51cto.com/lucifer119/1329869