I have a group of variables myLINEcnt1 - myLINEcnt10. I'm trying to printout the values using a for loop. I am at the head banging stage since i'm sure it has to be a basic syntax issue that i can't figure out.
For myIPgrp in 1 2 3 4 5 6 7 8 9 10; do
here i want to output the value of myLINEcnt[1-10]
but every attempt i've tried either errors or give me just the number portion (1-10)
echo ${myLINEcnt}${myIPgrp}
Crap, i'm an idiot. SORRY I'm using bash on a Centos 5.7 system.
You need to use eval to access dynamically generated variable names. And, as a further hint, with eval you'll need to quote the first $ . Since eval can execute arbitrary code, use it with caution. This particular use should be fine. Read your shell man page for the details.
Your shell may provide a better alternative. Perhaps arrays. Or references. If you want help with the bigger picture, tell us which shell and os you're using and what you're trying to accomplish.