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:
ToddAndMargo <[log in to unmask]>
Reply To:
ToddAndMargo <[log in to unmask]>
Date:
Fri, 6 Jun 2014 21:23:42 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (50 lines)
>> On Fri, Jun 6, 2014 at 8:52 PM, ToddAndMargo <[log in to unmask]
>> <mailto:[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
>>
>>

On 06/06/2014 09:09 PM, Patrick J. LoPresti wrote:
> x=abc
> eval ${x}Status=xyz
> echo $abcStatus
>
>   - Pat


Hi Pat,

   Wow.  I would have never figured that out on my own.

   Thank you!


Follow on question: this works, but I would like
to clean it up:

xx=ech
eval "$xx""o abc"
abc

-T

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ATOM RSS1 RSS2