Bill Duncan wrote: > Remember that while there are 14 patterns of years, leap years don't > impact Friday the 13th for January/February.. > > This isn't an exhaustive analysis, but a quick check for 300 years > didn't show any years without a Friday 13th.. > > ;-) > > $ for y in {1900..2199} ; do for m in {1..12};do cal $m $y|awk > 'FNR==1{m=$0}/^ 1/{print m}';done;done | awk '{y[$2]++} END {for > (i=1900;i<2200;i++) if (!(i in y)) print i}' > $
Aren't you making things more complex than needed, with so much pipes and awk? date(1) is your friend: For instance: $ for y in {1900..2199} ; do echo -n "$y "; for m in {1..12}; do date +%A -d $y-$m-13; done | grep -c Friday ; done shows there are between 1 and 3 Fridays per year. Or a mere listing: $ for y in {1900..2199} ; do for m in {1..12}; do date +%A -d $y-$m-13; done; done | sort | uniq -c | sort -rn That the most common weekday in these three centuries for the 13th is… you guessed it, Friday. Happy New Year to all of you, too. Although I plan to stay in 2015 for almost 10 days more! :-)