假设用户喂食时间:
read -p "Enter the start time you want to start(hh:mm:ss) " user_start_time
和正则表达式:
timePattern="[0-2][0-3]:[0-5][0-9]:[0-5][0-9]"
如果我做 :
if [ "$user_start_time" == "$timePattern" ]
#or if [ "$user_start_time" =~ "$timePattern" ]
then
echo "in if"
else
echo "in else"
fi
它不验证.....作为新手,我了解比较int
或string
但我们如何进行time
(日期也在那里,但date -d
解决了很多问题)
也有这个问题,但无法理解接受的答案!