Re: create variables in a loop?

Liste des GroupesRevenir à cu shell 
Sujet : Re: create variables in a loop?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.shell
Date : 30. May 2024, 03:47:58
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v38lsd$1ghas$1@dont-email.me>
References : 1
User-Agent : Pan/0.158 (Avdiivka; )
On Wed, 29 May 2024 12:57:06 +0200, Dr Eberhard W Lisse wrote:

for i in USD GBP do
$i=somevalue
done

Maybe you actually want a lookup table of, say, conversion factors in this
case?

    declare -A factors
    for i in USD GBP; do
        factors[$i]=somevalue
    done

    echo "${!factors[@]}"
    echo "${factors[@]}"

Output:

    GBP USD
    somevalue somevalue

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