Code:
$ cat 13months_ago
#! /usr/bin/ksh
for input in 20071115 20071105 20070105 ; do
year=${input%????}
day=${input#??????}
month=${input#????}
month=${month%??}
month=${month#0}
day=${day#0}
print -n $input $year $month $day
((year=year-1))
((month=month-1))
if ((!month)) ; then
((year=year-1))
month=12
fi
typeset -Z2 newday newmonth
newday=$day
newmonth=$month
output=${year}${newmonth}${newday}
print -- " -->" $year $month $day $output
done
exit 0
$ ./13months_ago
20071115 2007 11 15 --> 2006 10 15 20061015
20071105 2007 11 5 --> 2006 10 5 20061005
20070105 2007 1 5 --> 2005 12 5 20051205
$