how to check a valid time argument in Linux?
Hello
I am writing a bash script xxx, which need to pass an time argument while using . for example: xxx 4:30 ( 4:30 is 4:30 am ) I need to check in the script if the entered time is valid. if it is not valid , I will echo " invalid input " something. anyone could help? thanks in advance Ray |
A quick one...
Code:
$ echo "4:30" | grep '^[0-9][1-2]\{0,1\}:[0-5][0-9]' Code:
#!/bin/bash Code:
$ ./check_time.sh 9:12 Code:
$ ./check_time.sh 4:71 Code:
$ ./check_time.sh 12:15 Best regards, HMW |
Thanks.it is useful
Ray |
All times are GMT -5. The time now is 10:23 AM. |