Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #26: first Saturday after first full moon in Winter


comp / comp.unix.shell / Re: create variables in a loop?

SubjectAuthor
* create variables in a loop?Dr Eberhard W Lisse
+- Re: create variables in a loop?David W. Hodgins
+* Re: create variables in a loop?Kenny McCormack
|`- How to use "eval" (was: create variables in a loop?)Helmut Waitzmann
+- Re: create variables in a loop?Lew Pitcher
+- Re: create variables in a loop?Helmut Waitzmann
+- Re: create variables in a loop?Chris Elvidge
+* Re: create variables in a loop?Janis Papanagnou
|`* Re: create variables in a loop?Eberhard W Lisse
| `- Re: create variables in a loop?Kenny McCormack
+- Re: create variables in a loop?Lawrence D'Oliveiro
`- Re: create variables in a loop?Lawrence D'Oliveiro

1
Subject: create variables in a loop?
From: Dr Eberhard W Lisse
Newsgroups: comp.unix.shell
Date: Wed, 29 May 2024 10:57 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: nospam@lisse.NA (Dr Eberhard W Lisse)
Newsgroups: comp.unix.shell
Subject: create variables in a loop?
Date: Wed, 29 May 2024 12:57:06 +0200
Lines: 18
Message-ID: <lbog03FfbrqU1@mid.individual.net>
Reply-To: nospam@lisse.NA
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net FFWCrkJNJHQaTaiym7LPzAyleQQ27lzGXi1PFkwSweKwmivL5Q
Cancel-Lock: sha1:Q3CazFc2XMaetgdVqrwLV2aD8EA= sha256:V4EB6tEGCk8wAsQHplFRdQi+wwpiF1JmNjKjTmGwu4o=
Content-Language: en-US
View all headers

Hi,

I would like to do something like

for i in USD GBP
do
$i=somevalue
done

does not work, of course.

Any idea on how to create (and fill variables through a loop)?

greetings, el

--
To email me replace 'nospam' with 'el'

Subject: Re: create variables in a loop?
From: David W. Hodgins
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 11:48 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dwhodgins@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 07:48:41 -0400
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <op.2oi63fdaa3w0dxdave@hodgins.homeip.net>
References: <lbog03FfbrqU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 29 May 2024 13:49:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="df39f971c72343ed39ce69cf9c93b489";
logging-data="1196104"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bTVdjZp39X5Mkd/6XM/HAREHuHMvghRc="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:DOa3PayLaeQO+/nwwhU18TFOPqM=
View all headers

On Wed, 29 May 2024 06:57:06 -0400, Dr Eberhard W Lisse <nospam@lisse.na> wrote:
> Hi,
> I would like to do something like
> for i in USD GBP
> do
> $i=somevalue
> done
> does not work, of course.
> Any idea on how to create (and fill variables through a loop)?
> greetings, el

There are many tutorials for getting started with shell scripting available,
such as https://tldp.org/LDP/abs/html/index.html which has a "for/in loop"
example at https://tldp.org/LDP/abs/html/loops1.html

Which shell will you be working in?

Regards, Dave Hodgins

Subject: Re: create variables in a loop?
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Wed, 29 May 2024 12:09 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 12:09:31 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <v375tr$1iinj$1@news.xmission.com>
References: <lbog03FfbrqU1@mid.individual.net>
Injection-Date: Wed, 29 May 2024 12:09:31 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1657587"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <lbog03FfbrqU1@mid.individual.net>,
Dr Eberhard W Lisse <nospam@lisse.NA> wrote:
>Hi,
>
>I would like to do something like
>
> for i in USD GBP
> do
> $i=somevalue
> done
>
>does not work, of course.

The general answer is to use "eval", so something like:

for i in USD GBP
do
eval $i=somevalue
done

But this doesn't scale well if "somevalue" is other than a simple string.
(But see below...)

Alternatively, with bash, you can use the "nameref" capability - see the
man page for details.

Update to add: this actually works:

for i in one two three;do eval $i='"$(fortune)"';done

--
"Every time Mitt opens his mouth, a swing state gets its wings."

(Should be on a bumper sticker)

Subject: Re: create variables in a loop?
From: Lew Pitcher
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 12:10 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitcher@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 12:10:32 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <v375vo$14a46$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: Wed, 29 May 2024 14:10:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="addc4a28d9fbe809e2a38ec28a140433";
logging-data="1190022"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18upN/4kpABAjw50onYyspSwdtYdB5FNjc="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:1TxMBExEtL4YTDDvhq9NoQUTLnY=
View all headers

On Wed, 29 May 2024 12:57:06 +0200, Dr Eberhard W Lisse wrote:

> Hi,
>
> I would like to do something like
>
> for i in USD GBP
> do
> $i=somevalue
> done
>
> does not work, of course.
>
> Any idea on how to create (and fill variables through a loop)?

echo $CAD $EUR
for i in CAD EUR
do
eval "$i=someval"
done
echo $CAD $EUR

The /eval/ operation is one of those "special built-in utilities
that POSIX mandates all POSIX shells must support

>
> greetings, el

--
Lew Pitcher
"In Skills We Trust"

Subject: Re: create variables in a loop?
From: Helmut Waitzmann
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 12:36 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 14:36:38 +0200
Organization: A noiseless patient Spider
Lines: 43
Sender: Helmut Waitzmann <12f7e638@mail.de>
Message-ID: <83ed9k94mh.fsf@helmutwaitzmann.news.arcor.de>
References: <lbog03FfbrqU1@mid.individual.net>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Date: Wed, 29 May 2024 14:44:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="25f5800519cb856ac6a17ee9327ec4a5";
logging-data="1213295"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+iUe5NqxqIK5lJhDS642PUxIwNZAHaY60="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Cancel-Lock: sha1:4jhk0KI/GJzyxtiZ04OZVgmkULI=
sha1:ok90mRRjfYHT4CS7d4OTE85uK8w=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
View all headers

Dr Eberhard W Lisse <nospam@lisse.NA>:
> Hi,
>
>
> I would like to do something like
>
>
> for i in USD GBP
> do
> $i=somevalue
> done
>
> does not work, of course.
>
>
> Any idea on how to create (and fill variables through a loop)?
>

Yes.

for i in USD GBP
do
somevalue=... &&
eval "$i"'="$somevalue"'
done

But note, that variable names consisting of only upper case
letters, digits, and underscores are by convention reserved for
the environment.  Therefore I recommend to do

for i in USD GBP
do
somevalue=... &&
eval 'currency_'"$i"'="$somevalue"'
done

instead, to get variables like currency_USD, currency_GBP, and so
on.

Subject: Re: create variables in a loop?
From: Chris Elvidge
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 13:05 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 14:05:40 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <v37975$157io$1@dont-email.me>
References: <lbog03FfbrqU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 29 May 2024 15:05:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="920d3e9ff34981a8b8ef77f9cfbe063f";
logging-data="1220184"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194iUcp5ppuE+y9aG5RhE5QUsfehilAjoo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:pmQwCCmHHd5cZpfg3iEbaQ100G8=
Content-Language: en-GB
In-Reply-To: <lbog03FfbrqU1@mid.individual.net>
View all headers

On 29/05/2024 at 11:57, Dr Eberhard W Lisse wrote:
> Hi,
>
> I would like to do something like
>
> for i in USD GBP
> do
> $i=somevalue
> done
>
> does not work, of course.
>
> Any idea on how to create (and fill variables through a loop)?
>
> greetings, el
>

declare $i=somevalue
possibly

--
Chris Elvidge, England
RALPH WON'T "MORPH" IF YOU SQUEEZE HIM HARD ENOUGH

Subject: How to use "eval" (was: create variables in a loop?)
From: Helmut Waitzmann
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 13:01 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nn.throttle@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: How to use "eval" (was: create variables in a loop?)
Date: Wed, 29 May 2024 15:01:50 +0200
Organization: A noiseless patient Spider
Lines: 45
Sender: Helmut Waitzmann <12f7e638@mail.de>
Message-ID: <83bk4o93gh.fsf_-_@helmutwaitzmann.news.arcor.de>
References: <lbog03FfbrqU1@mid.individual.net>
<v375tr$1iinj$1@news.xmission.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Date: Wed, 29 May 2024 15:14:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="25f5800519cb856ac6a17ee9327ec4a5";
logging-data="1223472"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LfyeG5flf2lkBSugxk+/3tRQBCYk1jhw="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Cancel-Lock: sha1:Y+8N5VX0WBaGbP2Ym8YpPXgga40=
sha1:y1XIHA6LzOXSh+GEr6dmls9uA2g=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mail-Copies-To: nobody
View all headers

gazelle@shell.xmission.com (Kenny McCormack):
> Dr Eberhard W Lisse <nospam@lisse.NA> wrote:
>> I would like to do something like
>>
>>
>> for i in USD GBP
>> do
>> $i=somevalue
>> done
>>
>> does not work, of course.
>>
>
> The general answer is to use "eval", so something like:
>
>
> for i in USD GBP
> do
> eval $i=somevalue
> done
>
> But this doesn't scale well if "somevalue" is other than a
> simple string.
>

First assign "somevalue" to a variable, not using "eval".  Then
assign that variable's value to the variable named by "$i", using
"eval"

somevariablename=... &&

# Note, that in the following assignment "..." may be any
# valid shell expression expanding to a string, not just
# a simple string:
#
somevalue=... &&

# Note, how the apostrophes are placed around the right
# hand part of the following assignment to be "eval"ed
# but not around the name of the receiving variable to be
# assigned to:
#
eval "$somevariablename"'="$somevalue"'

Subject: Re: create variables in a loop?
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 16:25 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 18:25:11 +0200
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <v37ktf$17c89$1@dont-email.me>
References: <lbog03FfbrqU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 29 May 2024 18:25:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="aeae80ca8ca6b6db907300a8339690ad";
logging-data="1290505"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PWcbUrDeQHtOcO1h0yfkS"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:9OYjNJgey/ZWG/OujBn7JCOzhEE=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <lbog03FfbrqU1@mid.individual.net>
View all headers

On 29.05.2024 12:57, Dr Eberhard W Lisse wrote:
> Hi,
>
> I would like to do something like
>
> for i in USD GBP
> do
> $i=somevalue
> done
>
> does not work, of course.
>
> Any idea on how to create (and fill variables through a loop)?

You've already got the technical answer to your (literal) question.
Basically something like

for currency in USD GBP EUR
do
eval "${currency}='some value $((++n))'"
done
printf "%s\n" "$USD" "$GBP" "$EUR"

But I suggest to reconsider your software design approach!

Mind that variables are for programmers, and that if you create
variable names dynamically you either have to hard code the names
in several places, or use 'eval' in several places; where ever you
want to access them. (Which requires additional tests, to be sure.)

Other approaches are (for example) defining data structures for
the allowed variable name values (and attributes)

currencies=( USD GBP EUR )
factor=( 1.2 1.5 1.0 )

value=4.3
for (( i = 0; i < ${#currencies[@]} ; i++ ))
do
printf "%s: %g\n" "${currencies[i]}" $(( ${value} * ${factor[i]} ))
done

or use control constructs (to differentiate interrogated dynamic
name values) like

for f in data_file_*
do
curr=${f##data_file_}
case ${curr} in
(USD) val=1.2 ;;
(GBP) val=1.5 ;;
(EUR) val=1.0 ;;
(*) exit 1 ;;
esac
done

to be able to tell apart allowed values from undefined and errors.

The question is; do I really want an *individual* _variable name_
created? (Or is the technical [variable] name actually just data?)

Janis

>
> greetings, el
>

Subject: Re: create variables in a loop?
From: Eberhard W Lisse
Newsgroups: comp.unix.shell
Date: Wed, 29 May 2024 17:45 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: nospam@lisse.NA (Eberhard W Lisse)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 19:45:28 +0200
Lines: 26
Message-ID: <lbp7tpF24jbU1@mid.individual.net>
References: <lbog03FfbrqU1@mid.individual.net> <v37ktf$17c89$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net VemnvQJ0IWl9fJmGbBHfqwbtKov3ovSOmhBY4a7wDGqkCUqXv8
Cancel-Lock: sha1:lPelxS0WVtlmWGdCA4P02AcLHbo= sha256:0HHLKLdV7pjszPP3IwJDmM+TsSkIfeamzrzBZ1Ab26o=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:115.0)
Gecko/20100101 Betterbird/115.11.0
Content-Language: en-US
In-Reply-To: <v37ktf$17c89$1@dont-email.me>
View all headers

On 29/05/2024 18:25, Janis Papanagnou wrote:
> On 29.05.2024 12:57, Dr Eberhard W Lisse wrote:
[...]
>> I would like to do something like>>
>> for i in USD GBP
>> do
>> $i=somevalue
>> done
>>
>> does not work, of course.
>>
>> Any idea on how to create (and fill variables through a loop)?
>
> You've already got the technical answer to your (literal) question.
> Basically something like
>
> for currency in USD GBP EUR
> do
> eval "${currency}='some value $((++n))'"
> done
> printf "%s\n" "$USD" "$GBP" "$EUR"
[...]

Thanks to all having answered.

greetings, el

Subject: Re: create variables in a loop?
From: Kenny McCormack
Newsgroups: comp.unix.shell
Organization: The official candy of the new Millennium
Date: Wed, 29 May 2024 18:31 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 18:31:38 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <v37saa$1ivar$1@news.xmission.com>
References: <lbog03FfbrqU1@mid.individual.net> <v37ktf$17c89$1@dont-email.me> <lbp7tpF24jbU1@mid.individual.net>
Injection-Date: Wed, 29 May 2024 18:31:38 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1670491"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

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...

Subject: Re: create variables in a loop?
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 29 May 2024 23:06 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: create variables in a loop?
Date: Wed, 29 May 2024 23:06:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <v38cd9$1bce2$2@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 01:06:18 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="26c065b9f57d6a6f7be8cfe25ea33754";
logging-data="1421762"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nYtPbfNRVT+AuwgCQRw4q"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:7cPWG0gD5XU6bPmC7c/K3D2ySXM=
View all headers

On Wed, 29 May 2024 12:57:06 +0200, Dr Eberhard W Lisse wrote:

> I would like to do something like
>
> for i in USD GBP do
> $i=somevalue
> done
>
> does not work, of course.

for i in USD GBP; do
declare -n a=$i
a=somevalue
done

echo $USD $GBP

output:

somevalue somevalue

This is in bash, of course.

Subject: Re: create variables in a loop?
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 30 May 2024 01:47 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
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=
View all headers

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

1

rocksolid light 0.9.8
clearnet tor