Hi,
I wrote a simple shell script which accepts the input value yearmonth in the format YYYYMM and displays the date as YYYY-MM-DD.Day will be 01 always.Please find the code below
#!/bin/ksh
export yearmonth_date=$1
print_usage() {
echo "usage: ${0##*/} <yearmonth_date> \n" \
" yearmonth_date a yearmonth_date value in the format YYYYMM" 1>&2
exit 1
}
# check for valid parameters
if [[ $# -eq 1 ]]; then
yearmonth_date =$1
else
print_usage
fi
year=$(echo "$yearmonth_date" | cut -c1-4)
month=$(echo "$yearmonth_date" | cut -c5-6)
day='01'
curr_month_date=$year-$month-$day
echo $curr_month_date
Now when I execute I am getting the below mentioned error
>ksh get_curr_date.ksh 200904
get_rcurr_date.ksh[11]: yearmonth_date: not found.
2009-04-01
Can anybody help me to resolve this error.?
Thanks