ok will tell u the exact story :
The files will appear in a folder called "processing" in a partular directory. The script should target this folder . I was just considering grep folder as an example. What happens is files appear in this processing folder every minute or so. they get processed and move to a folder called sent. Now if there is an error as u know ( blank line or name appearing on next line ) in any of the files they get stuck in processing folder and do not get to sent folder. The files are something lik this after the processing :
GURD0906
GURD0906trim$$
GURD0906Service
Now the file with size 0 will be GURD0906trim$$ ... but we cant edit this file as this will not contain anything. We need to edit GURD0906 file which has the error. So when the script runs it should find the file with size 0... consider the first 8 characters of that file and edit it to remove the error. This file should be moved back to the a folder called "IN" which is in the same place as the processing directory. all the other files like
GURD0906trim$$
GURD0906Service
and the the backed up original file GURD0906.bak
should be moved to a folder called "failed reports" which is also next to processing folder.
And the most important part is if there is no file with size 0. then nothing should be done and backup file should not be created. otherwise we will have disk space issue.
This is the whole thing.