Skip to content

Instantly share code, notes, and snippets.

@jonyesno
Created October 5, 2010 18:10
Show Gist options
  • Save jonyesno/612030 to your computer and use it in GitHub Desktop.
Save jonyesno/612030 to your computer and use it in GitHub Desktop.
#!/bin/sh
SPESHUL=0
START=1582 # start of Gregorian
END=2010
RANGE=$(( ${END} - ${START} ))
for YEAR in $( jot - ${START} ${END} ) ; do
# cal outputs fixed positioned columns, but need to ditch header and blank lines
FRI=$( cal 10 ${YEAR} | cut -c16,17 | tail +3 | grep -v '^\s*$' | wc -l )
SAT=$( cal 10 ${YEAR} | cut -c19,20 | tail +3 | grep -v '^\s*$' | wc -l )
SUN=$( cal 10 ${YEAR} | cut -c1,2 | tail +3 | grep -v '^\s*$' | wc -l )
# yes, string comparison is cheaper but you have to clean the strings first, meh
if [ ${FRI} -eq 5 ] && [ ${SAT} -eq 5 ] && [ ${SUN} -eq 5 ] ; then
SPESHUL=$(( ${SPESHUL} + 1 ))
fi
done
echo ${SPESHUL} ex ${RANGE}
@jonyesno
Copy link
Author

jonyesno commented Oct 5, 2010

[lemon@far ~] 0 $ ./bogus-october-thing.sh 
61 ex 428

lots more than 1 ex 823 per Twitter RT everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment