"The Variable : what it is and why we need them"
by UNIX god.
( translated from octal to human from the 1967 filmstrip )
In the beginning the art of accessing memory addresses the indigenous people used the ancient technique of interpolation to create, record, update, and destroy a little primitive memory binding known simply as a variable.
The variable which initially held a numerical value would eventually be endowed to hold a whole array of interesting values. In the early days when the variable was of no use any more one of the most respected of all of the indigenous tribe known only as the 'garbage collector' would free() the variable by sacrificing it to the natives' deity known simply as the heap.
Though the native scripture warned them of Undefined Behaviour ... stack overflow ... hellfire ... segfault
Seriously though break down what isn't working.
Start with your loop and counter as SirDice pointed out.
To do that experiment with
expr() directly in the command line. build a counter you can call line by line. (READ THE MAN PAGE)
Also take the time to investigate the man page for
sh(). I realise it's a long man page but it will be your best resource once you know the language( much like how our o'reilly books used to be) Hint: look at Quoting, Parameter Expansion, Command Substitution, Flow-Control Constructs and
test()... did I mention READ THE MAN PAGES.
The Almquist Bourne shell is a great shell to work with. It takes some getting used to.
For further tutorials and best practices I have always enjoyed reading the stuff on this site:
http://www.shelldorado.com/
a more direct link to save you a couple clicks off of Heiner's site:
http://www.shelldorado.com/shelltips/
Look at the beginner section.
After you get your bearings( in say 45 minutes) take the time to learn what NOT to do with the shell:
http://partmaps.org/era/unix/award.html
http://www.shelldorado.com/articles/ignorantsguide.html
Good luck! and don't forget READ THE
man() PAGES!
~