![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
use 'nawk' instead of 'awk' on Solaris.
|
|
#10
|
|||
|
|||
|
Quote:
thanks Perderabo....datecalc is the real answer to all date manipulations.... |
|
#11
|
|||
|
|||
|
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 |
|
#12
|
||||
|
||||
|
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
$
|
|
#13
|
|||
|
|||
|
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 |
|
#14
|
||||
|
||||
|
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.
|
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|