In article <
cc515fc0-3936-4bb0...@googlegroups.com>,
James <
hsle...@yahoo.com> wrote:
> x=hello
> y=world
>
> for f in x y; do
> echo $f=${$f}
> done
>
> How to do this correctly?
echo $f=${!f}
From
http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansi
on.html#Shell-Parameter-Expansion
If the first character of parameter is an exclamation point (!), it
introduces a level of variable indirection. Bash uses the value of the
variable 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.
--
Barry Margolin,
bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***