Solved

date command

Posted on 2002-04-29
4
246 Views
Last Modified: 2010-04-20
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 ??
0
Comment
Question by:arvind
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
newmang earned 50 total points
ID: 6978954
What about something like this?

typeset -i dow
typeset -i num
dow=`date +%w`
num=6-$dow
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
0
 
LVL 5

Author Comment

by:arvind
ID: 6979898
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.

0
 
LVL 5

Author Comment

by:arvind
ID: 6979907
Thnx newmang , Its working fine ....
0
 
LVL 5

Author Comment

by:arvind
ID: 6990563
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question