LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2014, 08:55 PM   #1
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Rep: Reputation: 29
Friday before last Tuesday of the month.


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
 
Old 09-23-2014, 09:03 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Isn't this going on in https://www.linuxquestions.org/quest...pt-4175519852/ ?
 
Old 09-23-2014, 09:04 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
You asked for help and got it, then spin off another thread on the same theme. Unlikely to generate much sympathy I suspect.
 
Old 09-23-2014, 11:44 PM   #4
Dafydd
Member
 
Registered: Oct 2008
Posts: 344

Original Poster
Rep: Reputation: 29
Quote:
Originally Posted by syg00 View Post
You asked for help and got it, then spin off another thread on the same theme. Unlikely to generate much sympathy I suspect.
I owe the website an apology, the first message got sent my mistake.
Was not intentionaly.

Dave
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
friday before the last Tuesday of the month -- script Dafydd Linux - General 7 09-25-2014 12:22 PM
How to find/display out last Friday's date of the month sunnysthakur Linux - General 11 03-29-2013 03:09 AM
cronjob to run a command at first friday of each month a9b8c2 Linux - General 5 10-19-2012 08:24 AM
dcron - run script last friday of month cotton213 Linux - Software 7 06-25-2012 04:03 PM
howto start a perl script only from tuesday to friday at 8.00 am ? cccc Linux - Newbie 4 03-19-2005 04:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration