Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #12078

Re: Only one Friday 13th coming in 2016

From Ángel González <angel@16bits.net>
Newsgroups gnu.bash.bug
Subject Re: Only one Friday 13th coming in 2016
Date 2015-12-22 04:04 +0100
Message-ID <mailman.362.1450753467.843.bug-bash@gnu.org> (permalink)
References <slrnn7g4tl.2r3t.knock_yourself_out@vps.jonz.net> <20151221151338.GW27325@eeg.ccf.org> <20151222010544.GA21298@linda>

Show all headers | View raw


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! :-)

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Only one Friday 13th coming in 2016 Ángel González <angel@16bits.net> - 2015-12-22 04:04 +0100

csiph-web