Re: Last Sunday of the Month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 04 April 2005 12:55 pm, Steve Buehler wrote:
> RHEL ES 3
> I can't seem to find this about the date command, but that doesn't mean it
> can't do it.  I have overlooked things in the past.
>
> 1.  Can the date command give you a date for the Last Sunday of a
> month?  Or do I have to go through a loop to check each day of the month to
> see if it is the last Sunday of the month?
>
> 2.  I can do a date --date="last sunday".  Is there a way to tell it to
> give me the date of 4 Sundays ago?  I tried date --date="4 sundays ago" and
> that didn't do it.
>
> Thanks
> Steve


Hi,
You can use -d to request a date by string, but i think it only uses 'next' or 
'last'.
date -d "last month"
Fri Mar  4 21:00:09 PST 2005

date -d "next sunday"
Sun Apr 10 00:00:00 PDT 2005

You could check if next sunday is the current month:
date -d "next sunday"|awk ' {print $2} ...does it = $thismonth?
That would be a lot easier to check than checking every day.

-- 
Pete Nesbitt, rhce
www.linux1.ca

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux