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
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 9 3 Days Ago 08:37 PM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 01:01 PM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 05:42 PM
Changing Creation Date to a Prespecified Date of a File In Unix monkfan UNIX for Dummies Questions & Answers 4 11-28-2006 04:15 AM
[kornshell] Getting the next weekday date rs_f01 UNIX for Dummies Questions & Answers 1 08-09-2005 08:34 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 12-16-2005
Registered User
 

Join Date: Dec 2005
Posts: 20
Hi all,

Thank you very much for your prompt responses.
I got some solution in the net its working fine in my desktop(windows 2000) with cygwin, but its giving bailing error in my server(Sun OS 5.8).
Could any one of you help me to solve the problem, the code is below.


#!/bin/ksh

dte='2003-06-11'

eval $(echo "${dte}" | awk -F- '{printf("year=%s month=%s day=%s\n", $1, $2, $3)}')

echo "year->[${year}] month->[${month}] day->[${day}]"

cal "${month}" "${year}" | awk -v day="${day}" '
FNR > 2 {
for(i=1; i <= NF; i++)
if ( $i == day) {
#printf("day->[%d] row->[%d]\n", $i, FNR-2)
printf("%d\n", (NF == 7 || FNR!=3) ? i-1 : i+(6-NF))
exit
}
}
'


Thanks in Advance
Rinku
Reply With Quote
Forum Sponsor
  #9  
Old 12-16-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
use 'nawk' instead of 'awk' on Solaris.
Reply With Quote
  #10  
Old 12-18-2005
Registered User
 

Join Date: Dec 2005
Posts: 23
Thumbs up it works sir...

Quote:
Originally Posted by Perderabo
Should Jan 1 be a zero or a one? Both schemes are in use.

Compute the mjd of January 1 for the year. (Should Jan 1 be 1? If so subtract one.) Subtract the result from the mjd of the date to get day-of-year.

thanks Perderabo....datecalc is the real answer to all date manipulations....
Reply With Quote
  #11  
Old 4 Weeks Ago
Registered User
 

Join Date: Oct 2008
Posts: 3
I wonder : Is there a way in a KSH shell what the yesterdays last business day is:
so for instance monday 03112008 (ddmmyyyy) should be give 31102008.
I've search this site but couldn't found something. Did also tried with Julians Day

I'm using AIX 5.2.0 with KSH shell pls give me a hand
Reply With Quote
  #12  
Old 4 Weeks Ago
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Code:
$ cat yesterbusinessday
#! /usr/bin/ksh

alias datecalc=./datecalc
echo "Enter year month day"
read year month day

if (($(datecalc -d $year $month $day) == 1)) ; then
        offset=3
else
        offset=1
fi
datecalc -j $(($(datecalc -j $year $month $day) - offset))
exit 0
$ ./yesterbusinessday
Enter year month day
2008 11 3
2008 10 31
$ ./yesterbusinessday
Enter year month day
2008 10 31
2008 10 30
$
Reply With Quote
  #13  
Old 4 Weeks Ago
Registered User
 

Join Date: Oct 2008
Posts: 3
thx Perderabo for the fast reply ,

but i got a problem with the
# ./yesterbusinessday
+ alias datecalc=./datecalc
+ echo Enter year month day
Enter year month day
+ read year month day
2008 11 3
+ ./datecalc -d 2008 11 3
./yesterbusinessday[7]: ./datecalc: not found.
+ (( == 1 ))
./yesterbusinessday[7]: == 1: 0403-057 Syntax error

Sorry i'm new
Reply With Quote
  #14  
Old 4 Weeks Ago
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
I don't have an AIX ksh to test so I can't help you there. As for datecalc, the second post in this thread links to it.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:29 AM.


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

Content Relevant URLs by vBSEO 3.2.0