Re: access of Variable

From: Chris F.A. Johnson (c.f.a.johnson_at_rogers.com)
Date: 09/07/03


Date: 7 Sep 2003 15:38:38 GMT

On Sun, 07 Sep 2003 at 08:39 GMT, barry wrote:
> I have some variables like this:
>
> FILE1="something"
> FILE2="someother"
> FILE3="otherthing"
> FILE4="somemore"
> .......
> .......
> FILE20="something more"
>
> N is calculated by some arithmetic, my problem is that I want to access the
> variable FILE{$N} after I got the result of N.
> How can I access that variable. $FILE{$N} will only get $N.

eval echo \$FILE$N

    Or:

eval xx=\"\$FILE$N\"

    Some shells, e.g. bash and ksh, have arrays so you could also use:

FILE[0]=something
FILE[1]=something

    Then:

echo ${FILE[0]}

-- 
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: Slabinski and Mingst/Stowe disagree in Pushing Gravity
    ... On Sun, 01 May 2005 Paul Stowe wrote: ... > There are many specific detail problems in the page you referenced. ... posts you referenced by "Barry" do not even pertain to ...
    (sci.physics.relativity)
  • Re: Roberts "popper" on OSWO, under water based lacquer
    ... On Sun, 26 Aug 2007 20:03:36 GMT, B A R R Y wrote: ... Barry - thanks! ... Any chance you have a "before" shot so we can see what ...
    (rec.woodworking)
  • Re: Lest We Forget.....
    ... nor the years condemn. ... At the going down of the sun and in the morning ... Bigbazza (Barry) Oz ...
    (uk.people.silversurfers)
  • Re: Exercise the First
    ... Barry wrote: ... Depends on the relative positions of the sun and the ball. ... And just how does entropy figure into this? ...
    (sci.physics.relativity)

Quantcast