Unix Shell - Simple date validation

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > October 2006 > Simple date validation





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Simple date validation
Derk

2006-10-20, 7:21 am

I want to perfom a simple date validation on a variable. I have got the
following script working, but I want it to fail if it does not match the
pattern

How do I reverse the test

--------------------------------------

case $p1 in
[0-3][0-9]/[0-1][0-9]/[0-9][0-9])
echo "Invalid"
exit 1 ;;
esac

... continue processing

--------------------------------------



Thanks

Derrick


Ed Morton

2006-10-20, 1:22 pm

Derk wrote:
> I want to perfom a simple date validation on a variable. I have got the
> following script working, but I want it to fail if it does not match the
> pattern
>
> How do I reverse the test
>
> --------------------------------------
>
> case $p1 in
> [0-3][0-9]/[0-1][0-9]/[0-9][0-9])
> echo "Invalid"
> exit 1 ;;
> esac


case $p1 in
[0-3][0-9]/[0-1][0-9]/[0-9][0-9]) : ;;
*)
echo "Invalid"
exit 1 ;;
esac

Regards,

Ed.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com