[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash question: reporting a variable named within a variable



On Thursday 03 April 2003 08:01 pm, Bob Proulx wrote:
> Craig Dickson wrote:
> >     echo $var=$(eval echo \$$var)
> 
> That works.  Personally I prefer to eval the entire line.  This way
> you only use one layer of processing rather than the two in the above.
> 
>   for var in FOO BLAH ; do
>     eval echo $var = \$$var;
>   done

The following works only in bash, but is smaller and faster:
for var in FOO BLAH ; do
  echo $var = ${!var};
done
--
Rob



Reply to: