bash question

Chris F.A. Johnson c.f.a.johnson-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Tue Oct 5 19:26:28 UTC 2004


On Tue, 5 Oct 2004, Peter L. Peres wrote:

>
> On Tue, 5 Oct 2004, Chris F.A. Johnson wrote:
>
>>> I have asked this before: how does one expand parameters in bash for 
>>> indirection ?
>>> 
>>> Specifically:
>>> 
>>> foo=123
>>> bar=foo
>>> 
>>> now, what do I do to get the contents of foo knowing bar. I.e.:
>>> 
>>> baz=?!?(bar) such that baz=123
>>> 
>>> (find the ?!? operator, without using the name foo explicitly). I tried 
>>> various ${:=} etc expansions with no luck.
>> 
>> In bash:
>> 
>> baz=${!bar}
>> 
>> In any Bourne-type shell (including bash):
>> 
>> eval baz=\$$bar
>
> Thanks a lot, that's it. Bash is an example of documentation overload imho. 
> Manpage has only 8377 lines (about 140 pages when printed on A4 paper - no I 
> did not print it out) and I tried to go through it several times. Otoh what 
> happens to ${!bar} if history expansion is turned on ? No problem ?

     Try it and see. (There's no problem.)

-- 
 	Chris F.A. Johnson                      http://cfaj.freeshell.org
 	=================================================================
                 Everything in moderation -- including moderation
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list