I thought this would be easy, but obviously, I am missing something here.
I have a bash script where I want the user to enter a date on the command line in the format DD-MMM-YYYY, lets use 19-MAY-2010
Now I want to check to make sure they enter a correctly format date.
I have tried everything I can find online to get this to work.
First I get the DD part and put it in a variable: SDF1=`echo $1 | awk -F- '{print $1}'
That successfully gets me a two digit 19 in the SDF1 variable.
Now here is where my headache begins.

I can't figure out how to setup the pattern matching so that a two digit number is matched and evaluated as being valid or invalid i.e. a two digit day or not.
I have tried if all sorts of versions of [0-3][0-3] or [0-3]\{2\}
I have tried all sorts of quoting and delimiting with logical and matching operators like -ne, -eq, !=
I've echoed the $SDF1 and piped it to grep and used '[0-3]\{2\}" and stuff like that.
Scripting would go something like this, obviously it is wrong, but what I tried recently:
if [[ "$SDF1" =~ [0-3]{\2\} ]]; then
echo ok
else
echo not ok
fi
This replys that 19: "not ok"
Can someone help me get the 19 or DD to be evaluated if it is a number?
Of course I am going to have to do the same with the MMM and the YYYY.
I sincerely appreciate any and all help that may come.
Regards
George