SCIENTIFIC-LINUX-USERS Archives

June 2014

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nico Kadel-Garcia <[log in to unmask]>
Reply To:
Nico Kadel-Garcia <[log in to unmask]>
Date:
Sat, 7 Jun 2014 12:25:22 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (24 lines)
On Fri, Jun 6, 2014 at 11:52 PM, ToddAndMargo <[log in to unmask]> 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.

ATOM RSS1 RSS2