Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Array Content to create other array's names 1

Status
Not open for further replies.

TSch

Technical User
Jul 12, 2001
557
DE
Hi folks,

here's another task I'm facing:

I'm using a dynamic array (e.G. set -A arrayA ...) to read the names of certain databases out of a command output.

Now what I'd like to do is create several new arrays for every entry in arrayA but the new arrays are supposed to have the entry as part of their names.

e.g.:

arrayA contains the following entries:
Code:
CARS
BIKES
MOTORCYCLES
STROLLERS

And the new arrays are supposed to be named like this:
Code:
Content_CARS
Content_BIKES
Content_MOTORCYCLES
Content_STROLLERS

Here's what I tried so far:

Code:
i=0
while [ $i -le 5 ];
do
set -A Content_${arrayA[$i]} $(cat ${arrayA[$i]}.txt)
i=`expr $i + 1`
done

But somehow it's not working.

Any ideas ?

Regards,
Thomas
 
Use the eval builtin.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top