![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |