The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-22-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
 

Join Date: Jul 2007
Location: PUNE
Posts: 171
Array inside an array

hi All,

I have a array as follows,

array1=("xx" "abc" "def" "xyz")
and each array1[index] is also storing some array values, like

array1[1]=abc
and abc=("a" "b" "c") etcetera etcetra.........

Note : each subarray under array1 have index 3 i.e. it can max contain 3 values

if i echo ${abc[index]} [ where index is 1,2,3...] it works fine.

but if i loop thru it's not printing the values, can anybody help me solving this thru loop,

my loop goes like this


cnt=1
total_Array=${#array1[*]}
no_loop_thru=${#abc[*]}

while [ $cnt -lt $total_Array ]
do
srch_fld=`echo ${array1[$cnt]}`
j=1
while [ $j -le $no_loop_thru ]
do
#var1=`$srch_fld[$j]`
#echo ${var1}
echo ${srch_fld[$j]}
j=`expr $j + 1`
done
cnt=`expr $cnt + 1`
done


can anybody suggest any improvement on this......LOOP
Reply With Quote
Remove advertisements
!!
Forum Sponsor