![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing Creation Date to a Prespecified Date of a File In Unix | monkfan | UNIX for Dummies Questions & Answers | 4 | 11-28-2006 07:15 AM |
| performing a task at regular intervals | mridula | High Level Programming | 2 | 11-14-2005 05:26 AM |
| mailing myself at regular intervals... | timepassman | Shell Programming and Scripting | 4 | 08-21-2005 09:11 PM |
| How to perform Date Intervals? | yongho | Shell Programming and Scripting | 2 | 06-21-2005 12:02 PM |
| Schedule a Batch file to delete files at particular intervals | Indom | Windows & DOS: Issues & Discussions | 6 | 02-04-2004 12:57 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Date Intervals
I posted a question on date intervals about a month back asking about how I could be able to go about a user entering the starting year/month/day and an ending year/month/day and then the script automatically cycling through each day of each month of each year that the user has specified. I checked out Perderabo's datecalc script and it was helpful but still not exactly what I needed. I've thrown together some code today but I know that it's not going to work, I just need some suggestions on how I can complete this. Code:
#!/bin/ksh
# Ja Fe Ma Ap My Jn Jl Au Se Oc No De
set -A DaysInMonth xx 31 28 31 30 31 30 31 31 30 31 30 31
isLeapYr=`date.isLeapYr.ksh`
if (( isLeapYr==1 )); then
DaysInMonth[2]=29
fi
while (( start_date_Y < end_date_Y )); do
while (( start_date_m < end_date_m )); do
while (( start_date_d < ${DaysInMonth[${start_date_d}]} )); do
(( start_date_d=start_date_d+1 ))
done
(( start_date_m=start_date_m+1 ))
done
(( start_date_Y=start_date_Y+1 ))
done
Some of my concerns are: Take a look at the start_date_m < end_date_m loop (the 2nd while loop). What if the starting month is 4 and the ending month is 10 (but the user meant the 10 month of the 2nd year) then the loop will break prematurely. How do I adjust for this? I'm continuuing to work on this script, so I will keep this post updated. Last edited by yongho; 07-29-2005 at 01:46 PM.. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|