0

Hi, I am creating a program that will validate if the user input date is correct.
My problem is checking the month,
1. Is it possible to save the all the months in an array and then check the array if the user input is correct.
2. How can it be possible?

Sorry I am new to shell scripting thats why I have so many questions.
Thanks in advance..

echo -n " Date [ DD-MON-YY ]:"  #user will input the date
            read date1 mon1 yy1
            datefn # call the function to check the input




datefn(a, b, c){

########## check the DAY #####################
    if [ "$a" -gt 0 ] && [ "$a" -le 31 ]
    then
        break ;;
    else
        echo "Month is OUT OF RANGE!"
    fi

########## check the MONTH #####################    
    1 = Jan
    2 = Feb
    3 = Mar
    4 = Apr
    5 = May
    6 = Jun
    7 = Jul
    8 = Aug
    9 = Sep
    10 = Oct
    11 = Nov
    12 = Dec

    if [ $b == 
    }

I dont know what to do next ~_~

2
Contributors
1
Reply
5
Views
4 Years
Discussion Span
Last Post by lewashby
0

I just wrote this program myself in bash. I created an array
CALENDER=(31 28 31 30 31 30 31 31 30 31 30 31)

Dealing with leap year is the trick part. If you want let me now and I'll supply my script.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.