date command

I would like the print the week(date)  like week 17 startdate of week and enddate of week. sunday is the start day of week .So result like :

week 17 7 April 2002 to 14 April 2002

Any body can ??
Who is Participating?
newmangConnect With a Mentor Commented:
What about something like this?

typeset -i dow
typeset -i num
dow=`date +%w`
week=`date +%U`
sunday=`date -d "today-$dow days" +"%e %B %Y"`
saturday=`date -d "today+$num days" +"%e %B %Y"`
echo +"Week $week $sunday to $saturday"

Cheers - Gavin
arvindAuthor Commented:
Here is the out put of ur script.
+Week 17 28 April 2002 to

So I would like the out put : Week 17, 7 April to 14 April 2002.

arvindAuthor Commented:
Thnx newmang , Its working fine ....
arvindAuthor Commented:
newmang one problem. PLs try to run this script on sunday or saturday. Its not giving the right output. Example I'd run this script sunday morning 7 AM _ I'd got week 18 5may to 6th may.

Could pls correct the problem
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.