Solved

date command

Posted on 2002-04-29
4
236 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now