"Ukazatele" v shellu
Alexej Sveshnikov
svesh na seznam.cz
Neděle Listopad 28 11:35:08 CET 2004
Faltynek Pavel wrote:
> Dobry den,
>
> je mozne v shell-skripu pristupovat k hodnote promenne, jejiz nazev je
> hodnotou jine promenne?
>
> napr.
>
> i="HOME USER PWD"
> for j in $i; do
> echo $$j #kdyby to slo, vypsalo by to obsah promenne HOME atd.
> done
>
> Dekuji za pripadne info.
> S pozdravem
> Pavel Faltynek
Z manualove stranky BASH'e:
If the first character of parameter is an exclamation point, a level of
variable indirection is introduced. Bash uses the value of the vari‐
able formed from the rest of parameter as the name of the variable;
this variable is then expanded and that value is used in the rest of
the substitution, rather than the value of parameter itself. This is
known as indirect expansion. The exception to this is the expansion of
${!prefix*} described below.
Tim padem:
i="HOME USER PWD"
for j in $i; do
echo ${!j}
done
Hezky den preji,
Alexej Sveshnikov
Další informace o konferenci Linux