Re: extrapoled variable

From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 01/28/05


Date: Fri, 28 Jan 2005 07:57:36 +0000

2005-01-27, 13:32(-06), William:
> "yannouch" <yann@yannouch.net> wrote in message
> news:84158b3a.0501271028.194f5160@posting.google.com...
>>
>> I want to get the content of FOOBAR in C using A and B, something like
>>
>> C=${$A$B}
>>
>> I've already done it before but can't remember the correct syntax.
>> Does anybody know ?
>
> eval 'C="$'$A$B\"
>
> should do it. -Wm
[...]

But then $A$B is subject to word splitting and filename
generation as they are not quoted. Also note that if $A is "1"
and $B is "2" for instance, it may not work as expected.

eval "C=\${$A$B}"

Should be enough.

-- 
Stéphane


Relevant Pages

  • Re: unexpected softupdate inconsistency
    ... > difficult to specify the filename as a command-line argument to rm. ... work on a file apparently named 'foobar'. ... wes@zaphod$ ls -lB foo* ...
    (freebsd-stable)
  • Re: extrapoled variable
    ... William wrote: ... >>I want to get the content of FOOBAR in C using A and B, ... >>I've already done it before but can't remember the correct syntax. ... Regards, ...
    (comp.unix.shell)