I have one script by which I am taking Extraction Schedule in the following format [HH:MM],[HH:MM],[HH:MM],......[HH:MM]
Here I want validate the Input from user is okey or not.
Let say i have one variable SCH
SCH=12:34,23:12,11:20
Could you please tell me how I will validate it.
HH & MM Both should be Numeric
HH should not Greater then 24
MM should not greater then 60
Note: Here I am using comma (,) as a delimeter.
I have one script by which I am taking Extraction Schedule in the following format [HH:MM],[HH:MM],[HH:MM],......[HH:MM]
Here I want validate the Input from user is okey or not.
Let say i have one variable SCH
SCH=12:34,23:12,11:20
Could you please tell me how I will validate it.
HH & MM Both should be Numeric
HH should not Greater then 24
MM should not greater then 60
Note: Here I am using comma (,) as a delimeter.
Myscript is test.sh is looks like
_________________________________
#!/bin/bash
echo -n "Enter Time schedule in the following format [HH:MM],[HH:MM],..:"
read Ext_Sch
for val in `echo $Ext_Sch |tr ',' '\n'`
do
tmp=""
tmp=`echo $val | grep "^[0-2][0-4]:[0-6][0-9]"`
echo " After getting the Value of tmp is $tmp"
if [ "$tmp" = "" ]
then
echo "Invalid Format !! Re-enter Time schedule in the following format [HH:MM],[HH:MM],..:"
continue
fi
break
done
-------------------
I want give input like 27:40,10:30,17:40
Here this scripts should validate the HH:MM !!!
Please help me out
Ghost Thanks for your quick response !!
Now I am using that date with in my script
-------------
echo -n "Enter Time schedule in the following format [HH:MM],[HH:MM],..:"
read Ext_Sch
date -d $Ext_Sch
count=`echo $?`
if [ $count -eq 0 ]
then
echo Valid
else
echo Wrong
fi
------------
[Sanjaytmp]$ sh tt.sh
Enter Time schedule in the following format [HH:MM],[HH:MM],..:28:33
date: invalid date `28:33'
Wrong
---------------------
[Sanjaytmp]$Enter Time schedule in the following format [HH:MM],[HH:MM],..:23:45
Thu Sep 27 23:45:00 IST 2007
Valid
Here I am getting the message in my output(show in bold letter) as well that I dun want.
Could you help me how I will ignore it.