I have a list a variables being used in an awk command. They are passed parameters for a script so their value is undetermined but I am trying to use them in a for loop.
My question is can I use the value of a variable as part of another variables name? Or is this a bad idea and if so is there another route I can take?
Example
awk -v var1=hi -v var2=howdy -v var3=greetings \
'BEGIN{for (i = 1; i <= 3; ++i) print var+i}'
Desired Output
hi
howdy
greetings