![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Validate date | giridher2000 | Shell Programming and Scripting | 2 | 09-15-2008 01:12 AM |
| validate against a file | chiru_h | Shell Programming and Scripting | 7 | 08-31-2006 04:15 PM |
| How to validate a CSV file? | ElCaito | Shell Programming and Scripting | 4 | 02-27-2006 05:31 PM |
| validate the file name | maykap100 | Shell Programming and Scripting | 2 | 08-30-2005 07:30 AM |
| validate | ruffenator | Shell Programming and Scripting | 3 | 01-22-2002 07:37 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. Thanks Sanjay |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Could anyone let me know if
SCH=12:34,23:12,11:20... N numbers How can I print like below 12:34 23:12 11:20 |
|
#3
|
||||
|
||||
|
Quote:
Code:
echo ${SCH} | tr ',' '\n'
|
|
#4
|
|||
|
|||
|
Bingo !!!
Thanks Vino Bro !! |
|
#5
|
|||
|
|||
|
Anyone who can help me !!!
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. Thanks Sanjay |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
if you have GNU date, it might be easier to do this method of checking
Code:
# date -d "18:99" date: invalid date `18:99' # echo $? 1 # date -d "18:59" Wed Sep 26 18:59:00 # echo $? 0 |
|||
| Google The UNIX and Linux Forums |