The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 55
Wink How to Validate

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
Reply With Quote
Forum Sponsor
  #2  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 55
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
Reply With Quote
  #3  
Old 09-27-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Quote:
Originally Posted by SanjayLinux View Post
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
Code:
echo ${SCH} | tr ',' '\n'
Reply With Quote
  #4  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 55
Bingo !!!

Thanks Vino Bro !!
Reply With Quote
  #5  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 55
Unhappy

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
Reply With Quote
  #6  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 55
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
Reply With Quote
  #7  
Old 09-27-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,580
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0