Dear Gurus,
I am a novice in shell scripts. I have a requirement where I need to move files every day from Current Folder to Archive folder.
Daily I will be receiving 5 files in the folder - /opt/data/feeds/.
The feeds folder has two sub-folders - Current and Archive.
For example the first day, the I receive file and names will be like:
File1_extract_08012011
File2_extract_08012011
File3_extract_08012011
File4_extract_08012011
File5_extract_08012011
The last 8 characters are the mmddyyyy.
Very first time Current folder will be empty so I just move the files from
/opt/data/feeds/ to /opt/data/feeds/Current.
Again the second day, I will be receiving the following files:
File1_extract_08022011
File2_extract_08022011
File3_extract_08022011
File4_extract_08022011
File5_extract_08022011
When I receive the files, I should the move the existing files from Current to Archive folder and then place the new files in the "Current" folder.
Also there is another condition where say for example on the third day, I receive only 3 out of 5.
File1_extract_08032011
File3_extract_08032011
File5_extract_08032011
In this case, the current folder should keep the file2 and file4 (which is from 08022011) and file1,3,5 (which is from 08032011). The file1,3,5(of 08022011) should be moved to Archive. The current folder should always have the most recent date for each file.
Also the archive folder should have only the last 6 days for each file.
So every day the current folder will have 5 files and Archive folder will have 30 files.
Please help me on this.
Thanks in advance.
Shankar