If you're asking how to normalise different dates into a single format so you can compare them, the following normalise function (along with a small test harness) will do that for you.
It first lower-cases the string then removes all characters that are neither alpha nor numeric.
Then, if it's neither alpha-number nor number-alpha, it just returns a suitable error value ?.
However, assuming it is of one of those formats, it separates it into day and month then returns it in a consistent format:
#!/usr/bin/env bash
normalise() {
# Lowercase it and remove non-alphanumerics.
str="$(echo "$1" | tr '[A-Z]' '[a-z]' | sed 's/[^a-z0-9]//g')"
# Check one of the allowed formats.
if [[ ! "${str}" =~ ^[0-9]+[a-z]+$ ]] ; then
if [[ ! "${str}" =~ ^[a-z]+[0-9]+$ ]] ; then
echo '?'
return
fi
fi
# Extract the day andd month, return normalised value.
day="$(echo "$str" | sed 's/[a-z]//g')"
mon="$(echo "$str" | sed 's/[0-9]//g')"
echo "${day}-${mon}"
}
echo $(normalise "Jul 22")
echo $(normalise "jUl-22")
echo $(normalise "juL22")
echo $(normalise "Jul.22")
echo $(normalise "22 jUl")
echo $(normalise "22-juL")
echo $(normalise "22Jul")
echo $(normalise "22.jUl")
echo $(normalise "22.jUl.1977")
The output of that script is:
22-jul
22-jul
22-jul
22-jul
22-jul
22-jul
22-jul
22-jul
?