Maciej Żenczykowski wrote: > On Sun, 4 Dec 2005, Robert wrote: > >> Does anyone have an elegant solution for finding the date of the 3rd >> Monday each month and the date of the Sunday preceding? (Sunday >> shouldn't be beyond my capabilities, once the Monday part is worked >> out.) >> For the past several years, I've been handling the chore using a file >> with a manually input list of dates -- which is about as elegant as >> driving a tack with a sledge hammer. >> _______________________________________________ > > How about something like: > > YEAR=2005 > MONTH=12 > for ((DAY=1;DAY<=31;++DAY)); do > LC_ALL=C TZ=UTC date -d "$YEAR-$MONTH-$DAY" > done | grep "^Mon " | head -n 3 | tail -n 1 > > Possibly without the TZ=UTC depending on your needs... > > Cheers > MaZe? Considering my nebulous request and your apparent lack of expertise in applied clairvoyance, fine. The "3rd Monday" part is used in generating reminders to a each of a group of OldFarts that gets together monthly to inventory aches, pains and, yes, empty chairs. The "Sunday before" requirement will be used to run a script (already working) to create a series of image files containing critical stuff, to be burned (manually) to DVDs to go with me to the meeting, to be given to a trusted person for safekeeping. The following is what I have now, stripped down to the bare essentials for clarity(?): [rj at mavis ~]$ crontab -l MAILTO="" * * * * * /home/rj/meetdate [rj at mavis ~]$ cat meetdate #!/bin/bash # meetdate /home/rj/NSS.sh 10/17/2005 11/21/2005 12/19/2005 1/16/2006 2/20/2006 3/20/2006 (etc., etc., etc....) [rj at mavis ~]$ [rj at mavis ~]$ cat NSS.sh #!/bin/bash while [ $((`date -d $1 +%s` + 55800)) -le $((`date +%s`)) ] ; do shift MM=$((`date -d $1 +%s` + 55800)) # 3:30 PM on the date passed MB=$((`date -d $1 +%s` - 88200)) # 4:30 AM on the previous day # I want to match only date, hour and minute. MBS=`date -d "1/1/1970 + $MB seconds" +%D" "%H":"%M` done if [ "`date +%D" "%H":"%M`" = "$MBS" ] ; then # # Go execute backup script # # echo Finished Backup Crap else echo "Nope! Next backup will be at " $MBS echo "Meeting will be on " $1" at 3:30 PM" fi [rj at mavis ~]$ As it stands now, I have to manually edit the file "meetdate" from time to time, adding another year or two of dates. It works fine but it just ain't pretty.