datestr='2015-05-1'
if echo $datestr |grep -Eq "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}" && date -d $datestr +%Y%m%d >/dev/null 2>&1
then
echo 'ok'
else
echo 'err'
fi
原文链接:https://www.f2er.com/bash/390187.htmldatestr='2015-05-1'
if echo $datestr |grep -Eq "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}" && date -d $datestr +%Y%m%d >/dev/null 2>&1
then
echo 'ok'
else
echo 'err'
fi
原文链接:https://www.f2er.com/bash/390187.html