I'm trying to validate a user's input when they enter a date into my bash script.
The correct format should be YYYY-MM-DD HH:MM:SS
What I have so far is this, but it's not quite right.
read -p "-" datetime
if [[ $datetime ! "*[^2000-2100]-[^01-12]-[^10-31] [^00-24]:[^00-60]:[^00-60]*" ]]
then
echo "Not a date"
fi
2100-02-31 24:60:60doesn't sound like a valid date/time to me... Even if the regex matching did work that way...