Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: How to find/display out last Friday's date of the month

  1. #11
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,148
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: How to find/display out last Friday's date of the month

    Because in the last days of the month, '0 friday' could fall in the next month so $trymonth would never be equal to $thismonth. No?

  2. #12
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: How to find/display out last Friday's date of the month

    Yes, in the days after the last Friday, but not on that last Friday. No? E.g the last Friday is 29th of this month. Your script will still work on this day, but not on 30th.

  3. #13
    Join Date
    May 2009
    Location
    Fareham, UK
    Beans
    Hidden!
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: How to find/display out last Friday's date of the month

    Sorry, last fridays date of the month is what you asked for, I see you wanted the date of the last friday in the month
    Catch me on Freenode - imark

  4. #14
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,148
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: How to find/display out last Friday's date of the month

    Quote Originally Posted by schragge View Post
    Yes, in the days after the last Friday, but not on that last Friday. No? E.g the last Friday is 29th of this month. Your script will still work on this day, but not on 30th.
    Hmm, yes. Never tested what happened with "date -d "0 $(date +%A)"". So iterating to 0 can be a solution.

  5. #15
    Join Date
    Aug 2011
    Beans
    15

    Re: How to find/display out last Friday's date of the month

    This also works for me

    cal 03 2013 | awk 'NR==1 {m=substr($1, 1, 3); y=$2} NF>5 {d=$6} END {print "Friday", m, d, y}'

  6. #16
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: How to find/display out last Friday's date of the month

    Combining this with the code suggested by diesch, I get
    Code:
    ncal -h|awk 'NR==1{m=substr($1,1,3);y=$2}/^Fr/{print"Friday,",m,$NF,y}'
    Just for fun, the same in sed:
    Code:
    ncal -h|sed -nr '1h;/^Fr/{G;s/.*( \w+) *\n *(\w{3})\w*/Friday, \2\1/p}'
    Last edited by schragge; March 29th, 2013 at 07:18 PM.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •