Assume a user fed time :
read -p "Enter the start time you want to start(hh:mm:ss) " user_start_time
and the regex :
timePattern="[0-2][0-3]:[0-5][0-9]:[0-5][0-9]"
if i do :
if [ "$user_start_time" == "$timePattern" ]
#or if [ "$user_start_time" =~ "$timePattern" ]
then
echo "in if"
else
echo "in else"
fi
It doesn't validates.....being newbie, i understand comparison of int
or string
but how we go about time
(date is there too, but date -d
solves lot of problems)
There is this question too but couldn't understand the accepted answer!!