On 6/7/2014 11:25 AM, Nico Kadel-Garcia wrote:
On Fri, Jun 6, 2014 at 11:52 PM, ToddAndMargo<toddandma...@zoho.com>  wrote:
Hi All,

In Bash script language, how do I create a variable name
from a variable?

I am trying to create a variable called "abcStatus"

x=abc
$xStatus=xyz

obviously doesn't work.  What am I doing wrong?

Many thanks,
-T
It's not really core to Scientific Linux itself, but:

For most bash cases where I've found myself wanting something like
this, I've usually wound up using "hashes" instead. The first hash,
abc, contains a list of variable names, abcstatus, abctime, abcdate,
abcowner, etc. that can then be referrenced to refer to other valures
or hashes as needed.
I agree with everything said so far, but would like to toss in a chapter from the Advanced Bash-Scripting Guide (ABS). The dangers are of course still present, but might give a bit better explanation about what is going on. I actually do have scripts I use that utilize the \$$var method.

http://www.tldp.org/LDP/abs/html/ivr.html

Reply via email to