[clue] bash/using variables in variable names
Raymond DeRoo
rderoo at deroo.net
Fri Jun 21 15:09:57 MDT 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20130621/c579f35b/attachment.html
More information about the clue
mailing list