check file date in one week ???


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check file date in one week ???
# 1  
Old 03-15-2006
check file date in one week ???

How do you write a code in ksh ??

Enter the start date: 20060228
d0 = 20060228;

2. Check for 7 days of report list 1 day after the d0
d1 = 20060301
d2 = 20060302
d3 = 20060303
d4 = 20060304
d5 = 20060305
d6 = 20060306

then cat d0.log d1.log d2.log d3.log d4.log d5.log d6.log > 7days.log
if missing one day will give a warning missing date ???
and lines = `cat 7 days.log | wc -l`

Example
$weeklycount 20060228
$lines=3650



Thanks
# 2  
Old 03-16-2006
hi
Genrating next date requires bit of too many ifs any way here si what i would plan to do .hope it helps. I have just given you idea as how you can proceed.
Once done post the code Smilie)))

#!bin/ksh

nextDate( ){
MM=`echo "$VAR1" | awk '{print substr($VAR1,1,2)}'`
DD=`echo "$VAR1" | awk '{print substr($VAR1,3,2)}'`
YYYY=`echo "$VAR1" | awk '{print substr($VAR1,5,4)}'`
# Do all your evaluations here
# Increase value of Day
DD=`expr $DD + 1`
If [[ $DD >31 ]] # for odd months
#increment month
If [[ $DD > 30 ]] # for even months
#increment month

#Same logic applies for year
#Dont forget leap year and February month

}

VAR1=20060101
d0=$VAR1
d1=nextDate $d0
d2=nexDate $d1
..
...
......

d7=nexDate $d6


if missing one day will give a warning missing date ???
Do cat one after another

cat d0.log > 7days.log
if [[$?!=0]]
echo $d0 file missing
#append rest data
cat d1.log >> 7days.log
if [[$?!=0]]
echo $d1 file missing


....
...
Do the same for rest of files

and Finally

lines = `cat 7 days.log | wc -l`
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies

2. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

3. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

4. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

5. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

6. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

7. Shell Programming and Scripting

need help to get last week date

Hi, How to get last week date ? Normally i use this command : But somehow this not working in SunOS And i try use this : But in SunOS only working only get last 6 days Cheers, (1 Reply)
Discussion started by: justbow
1 Replies
Login or Register to Ask a Question