Re: access of Variable
From: Chris F.A. Johnson (c.f.a.johnson_at_rogers.com)
Date: 09/07/03
- Next message: Chris F.A. Johnson: "Re: Deleting subset"
- Previous message: Chris F.A. Johnson: "Re: how to extract URLs from files?"
- In reply to: barry: "access of Variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Chris F.A. Johnson: "Re: Deleting subset"
- Previous message: Chris F.A. Johnson: "Re: how to extract URLs from files?"
- In reply to: barry: "access of Variable"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|