Re: Way OT: getting values of list of variables
"Karsten M. Self" <kmself@ix.netcom.com> writes:
> on Mon, Sep 24, 2001 at 01:27:16AM -0500, Jeremy (thinker5555@yahoo.com) wrote:
> >
> > Hi,
> >
> > I'm sorry about this being so OT, but I've been searching around in
> > documentation (man pages, books, scripting HOWTOs, etc) for a several hours
> > now, and I can't find anything that will answer my question.
> >
> > I have a series of variables that I'm importing to a bash script from another
> > file, and I need a way to run a loop to echo the contents of each one in
> > sequence. As an example, say this file has the following:
> >
> > var1=data1
> > var2=data2
> > var3=data3
> > var4=data4
> >
> > Is there some way I can make my script start with var1 and echo each one
> > through var4 WITHOUT hardcoding each seperate variable into the script?
>
> $ man bash
> search ^ *Arrays
Thank you!! This is exactly what I needed! I don't know why it never
crossed my mind to look at the bash manpage. I guess because none of the
bash scripting books I have never mentioned arrays, so I didn't think it was
even an available facility for bash. Anyway, thanks again!
Jeremy
Reply to: