bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using variables in variables names


From: Dirk H. Schulz
Subject: Re: Using variables in variables names
Date: Mon, 13 Mar 2006 22:08:25 +0100
User-agent: Mozilla Thunderbird 1.0.7 (Macintosh/20050923)

Paul Jarc schrieb:

"Dirk H. Schulz" <address@hidden> wrote:
ac=12  dings$ac=wasannersder
-bash: dings12=wasannersder: command not found

Variable names in assignments are not subject to expansion.  So since
"dings$ac", as-is, does not fit the syntax for variable names, it
isn't treated as an assignment.  This will work:
ac=12 eval "dings$ac=wasannersder"
And how do I reference it then?

ac=12
eval "dings$ac=wasannersder"
echo $dings12 wasannersder # that works echo $('$dings'$ac) # trying to substitute $ac before $dings...
-bash: $dings12: command not found

Is there any way to reference it without anticipating the result of indirect referencing?

Dirk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]