Many Thanks for the response Andryk.
A few questions ...
I had worked with a sample of 3 mails.
1) I am not sure is `seq150` works in Unix. So I had used
for i in 1 2 3 instead of
for i `seq 3`in the 1st line of your script.
2) In your script, in line no - 3,
echo s $i file.$i >> forpipe, I am not sure why was $i also echoed. For e.g. if there are 3 mails, then the file "forpipe" would look
like
s 1 file.1
s 2 file.2
s 3 file.3
Now when I had run your script, I got the following files created - file.1, fil2.2,file.3,1,2,3.
When I removed $1 from the script (line no 3), I got 3 files - file.1,file.2 and file.3.
3) The script runs fine if the number of mails = contents in the file forpipe.
for e.g.
the contents in the file file - forpipe is
s file.1
s file.2
s file.3
x
The number of mails = 3.
However when the number of mails = 4, and there are 3 files listed in forpilpe, the files are still created, but the mail 1-3 are not deleted. Am not sure why.
In my case, the mails can come any time, and a new mail could have come after the creation of forpipe, while the mails are being processed. I cannot process the email again, because each email is expected to be unique.
Is there a way out ?
Apologies for being so lengthly ... I hope I am making sense.
Many Thanks.