Sponsored Content
Full Discussion: monthly calculation
Top Forums Shell Programming and Scripting monthly calculation Post 302227225 by Perderabo on Wednesday 20th of August 2008 10:40:38 PM
Old 08-20-2008
Maybe this will help....
Code:
$ cat loopr
#! /usr/bin/ksh
#
# get current month and year
date '+%Y %m' | read year month
month=${month#0}   # drop leading zero

#
# back up one month
((month=month-1))
if ((!month)) ; then
       month=12
       ((year=year-1))
fi
echo $year $month

#
# compute last day of month
leap=0
if ((!(year%100))); then
       ((!(year%400))) && leap=1
else
       ((!(year%4))) && leap=1
fi
#                 ja fe ma ap ma jn jl ag se oc no de
set -A mlength xx 31 28 31 30 31 30 31 31 30 31 30 31
((leap)) && mlength[2]=29

last=${mlength[month]}

#
# loop
typeset -Z2 fmonth fday
day=1
while ((day<=last)) ; do
       fmonth=$month
       fday=$day
       h=lic${year}${fmonth}${fday}\*405\*.txt
       echo $h
       ((day=day+1))
done
exit 0
$ ./loopr
2008 7
lic20080701*405*.txt
lic20080702*405*.txt
lic20080703*405*.txt
lic20080704*405*.txt
lic20080705*405*.txt
lic20080706*405*.txt
lic20080707*405*.txt
lic20080708*405*.txt
lic20080709*405*.txt
lic20080710*405*.txt
lic20080711*405*.txt
lic20080712*405*.txt
lic20080713*405*.txt
lic20080714*405*.txt
lic20080715*405*.txt
lic20080716*405*.txt
lic20080717*405*.txt
lic20080718*405*.txt
lic20080719*405*.txt
lic20080720*405*.txt
lic20080721*405*.txt
lic20080722*405*.txt
lic20080723*405*.txt
lic20080724*405*.txt
lic20080725*405*.txt
lic20080726*405*.txt
lic20080727*405*.txt
lic20080728*405*.txt
lic20080729*405*.txt
lic20080730*405*.txt
lic20080731*405*.txt
$

 

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

shedule monthly reboot on first sunday

Hello, I looked around but can't find a clear answer on this. Is there a way to shedule a box to reboot say on the first sunday of every month? Does it involve the cron.monthly file somehow, I googled and can't find how those cron.weekly, cron.monthly files function... This would be for Suse 9... (8 Replies)
Discussion started by: benefactr
8 Replies

2. Post Here to Contact Site Administrators and Moderators

monthly membership??

Hi, Do we have monthly membership (VIP) in our forum? if not, do we have any plans for it? Regards, (1 Reply)
Discussion started by: clx
1 Replies

3. Shell Programming and Scripting

Execution problem with crom for monthly

I have to setup cron job for monthly and the month may be 30 or 31 Thanks, (2 Replies)
Discussion started by: lakshmikant
2 Replies

4. UNIX for Advanced & Expert Users

Autosys JOB on monthly basis

Dear All, Can someone tell me how do I setup autosys job where it needs to execute on monthly basis that too on 1st day of the month. Thanks. (3 Replies)
Discussion started by: shahnazurs
3 Replies

5. Shell Programming and Scripting

help with a script to have monthly sar reports

Hi I am still learning shell scripting, so for complex stuff, I need help. I would like to have a script that produces sar monthly reports, so that I can produce a graph from it! The idea is to use /var/adm/sa/<dir of sa files>Looking to hear from you. regards (4 Replies)
Discussion started by: fretagi
4 Replies

6. Shell Programming and Scripting

Archiving a log file on monthly basis

OS : RedHat Linux 6.2 Shell : Bash Our application write messages, warnings,..etc to the following log file . /app/cms/diagnostics/logs/cms_messages.log This file has become huge now. I want this file to be archived on monthly basis using a small shell script. ie. On the 1st day of... (1 Reply)
Discussion started by: omega3
1 Replies

7. Shell Programming and Scripting

Tar archives monthly

Hi, I want to archive files by month, is there anyway of this code looks better? find /tmp/w/ -type f -newermt '2014-01-01' ! -newermt '2014-02-01' | xargs tar -czvf files01.tar find /tmp/w/ -type f -newermt '2014-02-01' ! -newermt '2014-03-01' | xargs tar -czvf files02.tar find... (9 Replies)
Discussion started by: prpkrk
9 Replies
hdate_struct(3) 						libhdate C language						   hdate_struct(3)

NAME
hdate_struct - libhdate Hebrew date struct SYNOPSIS
#include <hdate.h> Data Fields int hd_day int hd_mon int hd_year int gd_day int gd_mon int gd_year int hd_dw int hd_size_of_year int hd_new_year_dw int hd_year_type int hd_jd int hd_days int hd_weeks Detailed Description libhdate Hebrew date struct Field Documentation int hdate_struct::hd_day The number of day in the hebrew month (1..31). int hdate_struct::hd_mon The number of the hebrew month 1..14 (1 - tishre, 13 - adar 1, 14 - adar 2). int hdate_struct::hd_year The number of the hebrew year. int hdate_struct::gd_day The number of the day in the month. (1..31) int hdate_struct::gd_mon The number of the month 1..12 (1 - jan). int hdate_struct::gd_year The number of the year. int hdate_struct::hd_dw The day of the week 1..7 (1 - sunday). int hdate_struct::hd_size_of_year The length of the year in days. int hdate_struct::hd_new_year_dw The week day of Hebrew new year. int hdate_struct::hd_year_type The number type of year. int hdate_struct::hd_jd The Julian day number int hdate_struct::hd_days The number of days passed since 1 tishrey int hdate_struct::hd_weeks The number of weeks passed since 1 tishrey Author Generated automatically by Doxygen for libhdate C language from the source code. Version 1.4 Sun Jan 8 2012 hdate_struct(3)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy