Iteration dependent variables in a loop
I'm writing a bash script where I will have a different amount of variables depending on another parameter.
So if parameter a=5, I'll need var1-5, but if a=3 I only need var1-3.
My inclination is to set this up in a for loop, and have the loop go from 1-5, each time setting the value of var$a. However, I have found that bash doesn't like it when you use a variable on the left side of the equals sign.
I am fairly new to bash, but I can't imagine this is impossible. I'm not so familiar with arrays in bash, and feel like that will probably end up being the answer.
Any thoughts or advice would be much appreciated.
Thanks so much.
-JAH
|