Hi,
I want to validate if the given input is a valid month (written in long month format)
Jan / Feb / Mar / Apr / May / Jun etc etc
This is what I've got with || (or statements):
#!/usr/bin/ksh
INPUT_DATE=$1
FORMATTED_DATE=`date | cut -f2 -d' '`
#If there's no input use the sysdate otherwise use the input
if [[ -z "$INPUT_DATE" ]] ; then
MONTH_TO_PROCESS=$FORMATTED_DATE
else
MONTH_TO_PROCESS=$1
fi
echo $MONTH_TO_PROCESS
if [[ "$MONTH_TO_PROCESS" = "Feb" || "$MONTH_TO_PROCESS" = "Jan" || "$MONTH_TO_PROCESS" = "Mar"]]; then
echo "$MONTH_TO_PROCESS is Valid"
else
echo "$MONTH_TO_PROCESS is Invalid"
fi
But when I use this for every month (jan - dec), the list is too long and I get an error.
This is what I want (but this is too long), how can i validate the month or cut all the or statements over multiple lines, I tried // but that doesn't work:
if [[ "$MONTH_TO_PROCESS" = "Feb" || "$MONTH_TO_PROCESS" = "Jan" || "$MONTH_TO_PROCESS" = "Mar" || "$MONTH_TO_PROCESS" = "Apr" || "$MONTH_TO_PROCESS" = "May" || "$MONTH_TO_PROCESS" = "Jun" || "$MONTH_TO_PROCESS" = "Jul" || "$MONTH_TO_PROCESS" = "Aug" || "$MONTH_TO_PROCESS" = "Sep" || "$MONTH_TO_PROCESS" = "Oct" || "$MONTH_TO_PROCESS" = "Nov" || "$MONTH_TO_PROCESS" = "Dec"]]; then