#!/bin/sh
REGEX="^[2][0-2]:[0-5][0-9]$"
TIME="21:30"
if [ $TIME = $REGEX ]; then
echo "Worked"
else
echo "Did not work"
fi
I guess it has something to do with the : but as far as I'm concerned, this is just a regular sign that needs no escape sequence.
bash if conditional regex
– gwillie May 31 '17 at 19:47