scripting tip needed

Alexandre Vieira nullpt at
Wed Jul 1 18:04:55 UTC 2009

Hi folks,

I'm having a little problem.

For exambe in ksh:

$ z=0
$ y=1
$ x=aaaa
$ eval `echo MACHINE_DISK$z[$y]`=$x
$ echo ${MACHINE_DISK0[1]}

My problem is getting back the value of the variable using variables to
refer to the variable name (confusing). I.e $MACHINE_DISK$z[$y] .

Using ${} works great when you only have a simple array but adding a
variable in the middle of the variable name seems to ruin it.

$ echo ${MACHINE_DISK0[$y]}
$ echo ${MACHINE_DISK$z[$y]}
ksh: ${MACHINE_DISK$z[$y]}: bad substitution

Thanks in advance for any tip

More information about the freebsd-questions mailing list