[clue] bash/using variables in variable names
Mike Bean
beandaemon at gmail.com
Fri Jun 21 15:26:28 MDT 2013
Would export work in a script? Huh... Arrays make some intuitive sense.
Why is it these projects are never as simple as you think they're going to
be when you start them?
Mike Bean
On Fri, Jun 21, 2013 at 3:09 PM, Raymond DeRoo <rderoo at deroo.net> wrote:
> Mike:
>
> export is your friend.
>
> OK, I am just thoroughly writer's blocked, probably missing something
> obvious; but who knows. Anyway, here's my question
>
> # node=somenode
> # echo $node
> somenode
> # somenodeVar=5 * // if this works*
> # echo $somenodeVar
> 5
> # $node"Var"=5 *// why doesn't this work?*
> bash: somenodeVar=5: command not found
>
>
> [16:06:18 rderoo at daggoo ~]$ node=somenode
> [16:07:03 rderoo at daggoo ~]$ echo $node
> somenode
> [16:07:49 rderoo at daggoo ~]$ export "${node}Var"=5
> [16:07:57 rderoo at daggoo ~]$ echo $somenodeVar;
> 5
> [16:07:58 rderoo at daggoo ~]$ echo $somenodeVar;
>
>
> For the time being well skip the discussion on why variable variables are
> bad and that one should really be using arrays...
>
> Kind Regards,
> Raymond
>
> _______________________________________________
> clue mailing list: clue at cluedenver.org
> For information, account preferences, or to unsubscribe see:
> http://cluedenver.org/mailman/listinfo/clue
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20130621/4e2b7d03/attachment.html
More information about the clue
mailing list