Ok .. so you have the pseudo'ish code ... what is your actual question?
Also, your following statement would seem counter productive:
I need to learn some bash programming. I will probably do it later
Does this imply you would like someone here to do this for you and when you get around to learning you will do more??