#!/bin/bash ############################################################################ # http://LinuxMeister.net/Scripts/while-loop.sh.html # john meister jan 2015 ############################################################################ # display calendar for each month of the year in a file for analysis # testing monthly myth that a month with 5 mondays, 5 Saturdays and 5 sundays # only happens once ever 823 years ############################################################################ echo "display months of year in long list by month" echo "showing months with 5 Mondays, 5 Saturdays and 5 Sundays" head -n 43 31find.sh | tee 5m5s5s.txt echo # set Y to first year of series Y=1900 # outside loop is the year, inside loop is the month while [ $Y -le 2016 ] # while the count is less than 2016 - YEAR do # outside loop - years cal -m 1 $Y | grep -B 8 ^31 | tee -a 5m5s5s.txt # if 31 is on a monday print calendar for that month cal -m 3 $Y | grep -B 8 ^31 | tee -a 5m5s5s.txt # if 31 is on a monday print calendar for that month cal -m 5 $Y | grep -B 8 ^31 | tee -a 5m5s5s.txt # if 31 is on a monday print calendar for that month cal -m 7 $Y | grep -B 8 ^31 | tee -a 5m5s5s.txt # if 31 is on a monday print calendar for that month cal -m 8 $Y | grep -B 8 ^31 | tee -a 5m5s5s.txt # if 31 is on a monday print calendar for that month cal -m 10 $Y | grep -B 8 ^31 | tee -a 5m5s5s.txt # if 31 is on a monday print calendar for that month cal -m 12 $Y | grep -B 8 ^31 | tee -a 5m5s5s.txt # if 31 is on a monday print calendar for that month Y=$(( $Y + 1 )) # increment variable YEAR by one done cat 5m5s5s.txt | grep -A 7 Jan | tee -a JANUARY-w-5m5s5s.txt cat 5m5s5s.txt | grep -A 7 Mar | tee -a MARCH-w-5m5s5s.txt cat 5m5s5s.txt | grep -A 7 May | tee -a MAY-w-5m5s5s.txt cat 5m5s5s.txt | grep -A 7 Jul | tee -a JULY-w-5m5s5s.txt cat 5m5s5s.txt | grep -A 7 Aug | tee -a AUGUST-w-5m5s5s.txt cat 5m5s5s.txt | grep -A 7 Oct | tee -a OCTOBER-w-5m5s5s.txt cat 5m5s5s.txt | grep -A 7 Dec | tee -a DECEMBER-w-5m5s5s.txt ############################################################################