Reference thread
Code:
http://www.linuxquestions.org/questions/programming-9/email-on-2nd-monday-and-3rd-monday-code-946376/from Nominal Animal dated 5-22-2012
responce from Nominal Animal.
Turns out I did not need the origianl snippet you provided. Today it is exactly what I need. I need to find the Friday before the last Tuesday of the month.
The modification to the code below I believe will do the job, with the exception of February and August. How do I handle something that occurs in the 3rd week of only a couple months?
Code:
#!/bin/bash
##http://www.linuxquestions.org/questions/programming-9/email-on-2nd-monday-and-3rd-monday-code-946376/
# Todays day abbreviation and day number, say "Fri 25".
# Use the POSIX locale explicitly, so we get English weekday abbreviations.
today="$(LC_ALL=C LANG=C date '+%a %d')"
if [ "${today%% *}" != "Fri" ]; then
# It is not Friday today.
exit 0
fi
# Which week of the month is it?
# The integer division ignores the fraction, so (day)/7+1
# yields the week number.
week=$((${today#* } / 7 + 1))
if [ $week -eq 4 ]; then
# It is the Friday before the last Tuesday of this month.
~/tffrobot/meeting-send.sh
fi