Validate Variables insert from user

Hi

Can you help me validate 2 variables?The first is an input date from the user and should be like this (yyyy-mm-dd). The second variable is an input time from the user and should be like this(hh:mm).When the input is wrong i want to give the chance to the user to insert again the date or time !! I appreciate your help. Its my 2nd script but never faced similar problem before!!

Peter!

date=$( ckdate -f "%Y-%m-%e" )

time=$( cktime )

thank u
it works for time but not for the date.When i enter for ex. 2009-01-13 then it asks me again to enter date

don't know what to tell you... cut-n-paste what i gave you works on my systems....

try just:

ckdate

on the command line and see if the default format works for you.

Ok i found the problem
it should be date=$( ckdate -f "%Y-%m-%d" ):stuck_out_tongue:

it works fine
thanks a lot.appreciate your help!!

oopsy!! sorry!

that was exact thing i was trying to avoid using "e". doh!

well i have another issue..Don't know if you can help me..
I read a variable from the user and then i use awk to search a file to find matching dates with the variable given so i can print the line(the folder its like a calendar)! I wrote this code but its completely wrong.

echo Give the date you wish ti display
read date
awk '{ if ($1=$date) print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6}' <file

Looks like you trimmed your post accidentally...

won't grep work for this?

ie

grep $date some_file

Using awk, you'd do something like this:

awk "/$date/" some_file

double-quotes necessary.

Hi All,

I have developed a script to validate the input parameter. The parameter is date & should be in YYYYMMDD format

date=$( echo $1 |ckdate -f "%Y%m%d")| true

if [[ $? == 0 ]]
then
print " success"
else
print "no success"
fi

but in whatever format i pass the parameter, it shows "Success". Can someone help me where i am wrong?