The UNIX and Linux Forums  

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



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-25-2002
Perderabo's Avatar
Perderabo Perderabo is online now
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,718
Code:
#! /usr/bin/ksh

#              ja fe ma ap ma ju ju ag se oc no de
set -A lasts 0 31 28 31 30 31 30 31 31 30 31 30 31

typeset -Z2 dmonth dday

#
#  loop on years

year=2001
while ((year<2003)) ; do

#
#  is this a leap year?
        leap=0
        if ((!(year%100))); then
                ((!(year%400))) && leap=1
        else
                ((!(year%4))) && leap=1
        fi

#
#  set number of days in february
        lasts[2]=28
        ((leap)) && lasts[2]=29
#
#  loop on month
        month=1
        while ((month<13)); do

#
#  loop on day
                day=1
                while((day<(lasts[month])+1)) ; do
                        dday=$day 
                        dmonth=$month
                        echo ${year}${dmonth}${dday}
                        ((day=day+1))
                done
                ((month=month+1))
        done

        ((year=year+1))
done
exit 0
Reply With Quote