Created
October 5, 2010 18:10
-
-
Save jonyesno/612030 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lots more than 1 ex 823 per Twitter RT everywhere.