Deutsch   English   Français   Italiano  
<v38lsd$1ghas$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Thu, 30 May 2024 01:47:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <v38lsd$1ghas$1@dont-email.me>
References: <lbog03FfbrqU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 30 May 2024 03:47:58 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="26c065b9f57d6a6f7be8cfe25ea33754";
	logging-data="1590620"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+duFGzelWkxkteLsijAYoN"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:CP5Qn1T+6C9M6NQrtRv/CoXnq7E=
Bytes: 1320

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