So is your question about temporary files, or about how to write the script?
If your question is about temporary files, what is your question?
If your question is about how to write the script, and you don't know much about shell scripting, get cracking and learn it! (grins) Google for
Otherwise, maybe you want to post the script you have written so far and ask a specific question about it.
Hope this helps you get started.