The UNIX and Linux Forums  

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


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Looping through files... Fred Goldman Shell Programming and Scripting 6 11-08-2007 03:50 PM
Looping on a list of files... lazerfoursix Shell Programming and Scripting 23 04-09-2007 06:18 AM
Looping/Repetition in Batch files kimpot7268 UNIX for Advanced & Expert Users 1 12-10-2005 01:49 AM
Help looping through files, please... kapolani Shell Programming and Scripting 2 10-27-2004 10:28 AM
looping files dharmesht Shell Programming and Scripting 5 12-03-2003 03:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-12-2008
Registered User
 

Join Date: Apr 2008
Posts: 5
Looping through files with date component

I have a list of files which has format: RECVD-YYYY-MM-DD-binry
I would like to get the files with the highest and lowest dates, and process them sequentially. For example, I have:
RECVD-2008-05-12-binry
RECVD-2008-05-13-binry
RECVD-2008-05-14-binry
RECVD-2008-05-15-binry
RECVD-2008-05-17-binry
RECVD-2008-05-19-binry
RECVD-2008-05-20-binry

I would like to get the file with the least date, that is RECVD-2008-05-12-binry and the max date which is RECVD-2008-05-20-binry. Then, process the files one by one starting from lowest date to highest date. If the file is missing, write it to a MISSED file. So the pseudocode will look like this:

MinDate = date of file in the list which has min date
MinDate = date of file in the list which has max date
dummy = MinDate;

For dummy <= Maxdate
loop
If RECVD-<dummy>-binry exists
then
process
else
write to MISSED file RECVD-<dummy>-binry
end if;
dummy + 1
end loop

Thanks a lot in advance..
Reply With Quote
Forum Sponsor
  #2  
Old 05-12-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 123
Hi,


For findind the max and min date,

sort -t"-" -k2,2 -k3,3 -k4,4 filename >> temp

Maxdate=`cat temp | tail -1`
Mindate=`cat temp | head -1`

Remaining can be done as per the pseudo code

Thanks
Penchal
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0