pdathu
1
Hi All,
I want chage the date value YYMM to YYYYMM in my script.
I am trying, but not get it.
Eg: 1109 changed to 201109.
$(if [[ $ARCHIVE_DT == "." ]] then
echo "1"
else
echo "update_month<=$ARCHIVE_DT"
fi)
Through above i got "update_month<=1109" in else, but i must get it "update_month<=201109"
Please help me in this
Thanking in advance.....
Regards.
dathu
agama
2
Have you tried something like this:
ARCHIVE_DT="1109"
if (( ${#ARCHIVE_DT} < 6 ))
then
ARCHIVE_DT="20$ARCHIVE_DT"
fi
echo "new date: $ARCHIVE_DT"
This will add 20 to the front of the date if it is not already 6 characters long. Works in Kshell and should work in bash.
sinnud
3
temp=$ARCHIVE_DT
if [[ $temp < 2000 ]]; then
ARCHIVE_DT=20$temp
else
ARCHIVE_DT=19$temp
fi
Here year range is 1920 to 2019...
pdathu
4
Thanks for reply.
suppose ARCHIVE_DT value: 9910, but i didn't get 199910 through the above code
---------- Post updated at 07:56 PM ---------- Previous update was at 07:43 PM ----------
Thanks sinnud.
But this code is limited. My year value ranges to 1995 to 2099.
Please help me.
Thanks in advnce...
Regards,
Dathu
sinnud
5
Then you need to decide, for example, 9610, to be 209610 or 199610. If you cannot decide, the script cannot...