it should be relatively easy to assemble
all the pieces and create—finally—the
script that details when a specific date
was on a specific day of the week.
I won’t republish all the code from
previous months (the completed script is
83 lines long), but here’s the most salient
portion at the end, the section that steps
back year by year to figure out which
one has a matching calendar entry:
echo Looking for $weekday, $day, $month \($monthnum\) \
starting in $mostrecent
now we need to loop backwards through years until a match
WORK THE SHELL
COLUMNS
year=$mostrecent
DOW=-1 start with a dead value
while [ $DOW -ne $desiredDOW ]
do
figureDOW $day $monthnum $year
echo "> $day $month occurred on a $DOW in $year"
year=$(( $year - 1 ))
done
echo "Got it! $day $month occurred on a $weekday
;most recently in ${year}:"
cal $month $year
Notice that when we find a match, we
not only print out what year had that
Develop.
Scale.
Deploy.
Full root access on your own virtual server for as little as $19.95/mo
0XOWLSOH; /LQX[; GLVWULEXWLRQV; WR; FKRRVH; IURP; ; :HE;EDVHG; GHSOR\PHQW; ; )LYH; JHRJUDSKLFDOO\;
GLYHUVH;GDWD;FHQWHUV; ;'HGLFDWHG;, 3;DGGUHVV; ;3UHPLXP;EDQGZLGWK;SURYLGHUV; ;;;FRUH;603;;HQ;
LQVWDQFHV; ;2XW;RI;EDQG;FRQVROH;DFFHVV; ;3ULYDWH;EDFN;HQG;QHWZRUN;IRU;FOXVWHULQJ; ;, 3;IDLO;RYHU;
VXSSRUW;IRU;KLJK;DYDLODELOLW\; ;(DVLO\;XSJUDGH;RU;DGG;DGGLWLRQDO;/LQRGHV; ;)UHH;PDQDJHG;' 16;;;;;