Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 108:20:30 |
Calls: | 290 |
Files: | 905 |
Messages: | 76,683 |
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
Hi,
I would like to do something like
for i in USD GBP
do
$i=somevalue
done
does not work, of course.
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
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
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)?
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.
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
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
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
$i=somevalue
done