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
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