Re: create variables in a loop?

Liste des GroupesRevenir à cu shell 
Sujet : Re: create variables in a loop?
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shell
Date : 29. May 2024, 19: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 to
comp.lang.c...


Date Sujet#  Auteur
29 May 24 * create variables in a loop?12Dr Eberhard W Lisse
29 May 24 +- Re: create variables in a loop?1David W. Hodgins
29 May 24 +* Re: create variables in a loop?2Kenny McCormack
29 May 24 i`- How to use "eval" (was: create variables in a loop?)1Helmut Waitzmann
29 May 24 +- Re: create variables in a loop?1Lew Pitcher
29 May 24 +- Re: create variables in a loop?1Helmut Waitzmann
29 May 24 +- Re: create variables in a loop?1Chris Elvidge
29 May 24 +* Re: create variables in a loop?3Janis Papanagnou
29 May 24 i`* Re: create variables in a loop?2Eberhard W Lisse
29 May 24 i `- Re: create variables in a loop?1Kenny McCormack
30 May 24 +- Re: create variables in a loop?1Lawrence D'Oliveiro
30 May 24 `- Re: create variables in a loop?1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal