Re: date/getdate.y: Relative days

"Colin S. Miller" <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization SunSITE.dk - Supporting Open source
Message-ID <[email protected]>
Akim Demaille wrote:
> I'm trying to find a means, given a week number, to find the date of
> the Monday and Friday.  I was wondering if I could use GNU date to do
> that straightforwardly instead of having to program this.
> 

Akim,

%u (numerical-day-of-week) is useful here

This should work


DATE="10 august 2007"  # a random date
OFFSET=$(( $(date --date="${DATE}" +%u ) - 1))
date --date="$DATE $OFFSET days ago"

HTH,
Colin S. Miller



BTW,
The first week (before the week's start day),
can be week 0 in some systems.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.