Are you the one saying you need to do it in a shell script or is this part of the requirements? The reason I ask... with you being new to scripting I'm already thinking of many different "red-flags" of things you would need to account for that would be an interesting endeavor for anybody new to scripting.
i.e. multiple incoming requests
If you have a good knowledge of *nix and the tools that are generally bundled with the OS. Then, ok, it's just syntax and you'll probably be able to figure it out considering you have some programming experience.
Otherwise, I'd write something you could run out of tomcat that you could use to interface with a database (not saying it can't be done with a shell script, it would just be more familiar to you) or use it to control your file i/o in a stricter fashion.
Just my humble opinion and speaking from past experience, many times I've gotten over my head because I wanted to try something new and didn't reuse my current tools/repertoire.