![]() |
|
|
|
|
|||||||
| 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 |
| validating data | joanneho | Shell Programming and Scripting | 1 | 10-08-2006 09:03 AM |
| validating 10. IP address any way possible | nrodolfich | Shell Programming and Scripting | 1 | 02-28-2006 12:58 PM |
| Validating date in sas | radhika03 | Shell Programming and Scripting | 1 | 09-16-2005 02:33 AM |
| Validating $1 and $2 before using | nhatch | Shell Programming and Scripting | 6 | 09-17-2003 10:01 AM |
| validating input | ruffenator | High Level Programming | 4 | 04-24-2002 05:30 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
This is what I have to check date entries in an interactive script with the end users... I use this to build control cards for a reporting utility supplied by a software vendor.
I also want to check to make sure its a valid day based on the month (ie 30days has sept, april, june and Nov..)... whats the best way to go that deep? I'm working in digital unix ksh. thanks! while :; do echo "Enter starting invoice date (CCYYMMDD or Quit): \c" read DATE1 CENT1=`echo $DATE1 | cut -c1,2` YR1=`echo $DATE1 | cut -c3,4` MO1=`echo $DATE1 | cut -c5,6` DD1=`echo $DATE1 | cut -c7,8` case "$CENT1" in 19 | 20 ) ;; * ) echo "Invalid Century, please re-enter entire date. \n" ;; esac case "$MO1" in 01|02|03|04|05|06|07|08|09|10|11|12 ) ;; * ) echo "Invalid Month, please re-enter entire date. \n" ;; esac |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Take a look at my datecalc routine. You can use the -j option to validate a date.
datecalc -j 2000 2 29 returns a Modified Julian Day Number while datecalc -j 2002 2 29 returns an error message. In either case the return code is set. The error message goes to stderr while the MJD goes to stdout. datecalc is here. |
|
#3
|
||||
|
||||
|
WOW ! Looks great!
I did a search before I did my posting and I thought I searched on "date" but I don't believe that post came up. ??? |
||||
| Google The UNIX and Linux Forums |