Re: bash question: reporting a variable named within a variable
On Thu, Apr 03, 2003 at 01:58:35PM -0800, Corey Hickey wrote:
> This isn't exactly a debian-specific question, but I'm not sure where
> else to turn.
>
> I'm writing a bash script wherein I have a list of variables of which I
> want to return the values. A script representative of what I am trying
> to do would be like this:
>
>
> #!/bin/bash
>
> FOO=bar
> BLAH=blarg
>
> for var in FOO BLAH ; do
> echo $var = $"$var" #this part is messed up
> done
Try this, which I believe to be the best way:
echo '$var = ' `eval 'echo "$foo"'`
Cheers,
--
Colin Watson [cjwatson@flatline.org.uk]
Reply to: