bash question
Peter L. Peres
plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Tue Oct 5 13:18:13 UTC 2004
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 ?
Peter
--
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