UNIX validate date
Validates a date in YYYYMMDD format
# EOM_DATE
debug echo “$(now): Validating EOM_DATE: $EOM_DATE”
CHK_YEAR=${EOM_DATE:0:4}
CHK_MON=${EOM_DATE:4:2}
CHK_DAY=${EOM_DATE:6:2}
debug echo “$(now): CHK_YEAR: $CHK_YEAR”
debug echo “$(now): CHK_MON: $CHK_MON”
debug echo “$(now): CHK_DAY: $CHK_DAY”
cal $CHK_MON $CHK_YEAR 2> /dev/null | grep -q $CHK_DAY
if [ $? -eq 0 ]
then
debug echo “$(now): EOM_DATE: $EOM_DATE is valid”
else
log echo “$(now): ERROR running: $THIS_SCRIPT $@”
log echo “$(now): ERROR: EOM_DATE: $EOM_DATE is invalid.”
usage
error_exit
return 5
fi