The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Get date and time for past 1 hour from current date spch2o Shell Programming and Scripting 5 1 Week Ago 01:32 AM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 12:01 PM
How to Calculate weekly date range mamta UNIX for Dummies Questions & Answers 1 03-06-2008 02:50 AM
How can I use mathematic calculate in date? guitaroa47 Shell Programming and Scripting 1 06-05-2007 04:37 AM
File date vs Current date trexlim Shell Programming and Scripting 4 05-04-2007 06:35 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-26-2008
Registered User
 

Join Date: May 2007
Posts: 54
calculate the date of next satureday of current date.

I want to calculate the date of next satureday of current date using shell script.

Suppose, today is 27-feb-08
I want to get the date of next satureday, which means 01-mar-08, in the formate '' YYMMDD ".

I do this in ksh..

Please tell me any type of command which help me out.

Thanks in advance...

Last edited by rinku; 02-26-2008 at 08:17 PM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-27-2008
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,226
Got gnu date?
Code:
$ date -d 'next sat' '+%y%m%d'
080301
Reply With Quote
  #3 (permalink)  
Old 5 Days Ago
Registered User
 

Join Date: May 2008
Location: India
Posts: 2
Post

The date -d option is not working for me...

I want to find the future date i.e. next monday.
The date format be anything just need to have a validation check for my application program. Help me on this.
Reply With Quote
  #4 (permalink)  
Old 5 Days Ago
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,226
Try this function...
Code:
#!/usr/bin/ksh

function dayshift {
  perl -e '@f = localtime(time+(86400*$ARGV[0]));
    printf "%04d%02d%02d\n", $f[5]+1900, $f[4]+1, $f[3];' -- $1
}

NEXT_MONDAY=$(dayshift $((8-$(date '+%u'))))
...format is YYYYMMDD, but change the printf if you want.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0