Date: Wed, 1 Jul 2009 18:40:00 +0100 From: Alexandre Vieira <nullpt@gmail.com> To: freebsd-questions@freebsd.org Subject: scripting tip needed Message-ID: <755cb9fc0907011040o28b82cdbjd5760b139f797050@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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]}
aaaa
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]}
aaaa
$ echo ${MACHINE_DISK$z[$y]}
ksh: ${MACHINE_DISK$z[$y]}: bad substitution
Thanks in advance for any tip
Cheers
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?755cb9fc0907011040o28b82cdbjd5760b139f797050>
