Sujet : Re: create variables in a loop?
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shellDate : 29. May 2024, 20:31:38
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <v37saa$1ivar$1@news.xmission.com>
References : 1 2 3
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
lbp7tpF24jbU1@mid.individual.net>,
Eberhard W Lisse <
nospam@lisse.NA> wrote:
...
Thanks to all having answered.
>
greetings, el
Note that most responders have suggested "eval" (starting with yours
truly), but I really think you should look into the "nameref" facility in
bash. That's really the best solution - easier to use and more flexible
than "eval".
Here's an example:
declare -n foo
unset zzz one two three
for foo in one two three;do foo=$((++zzz));done
echo $one, $two, $three
-- Just for a change of pace, this sig is *not* an obscure reference tocomp.lang.c...