
10-14-2008
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
No shell that I know of has multidimensional arrays (but awk does).
You can use the contents of an array as an element in another array, but it will no longer be an array. You may be able to reconstruct an array from it.
For example:
a1=( 1 2 3 4 5 6 7 8 )
a2=( a b c d e f g h )
b=( "${a1[*]}" "${a2[*]}" )
printf "%s\n" "${b[@]}"
-->
Code:
a1=( 1 2 3 4 5 6 7 8 )
a2=( a b c d e f g h )
b=( "${a1[*]}" "${a2[*]}" )
printf "%s\n" "${b[@]}"
To reconstruct the arrays:
a1=( ${b[0]} )
a2=( ${b[1]} )
-->
Code:
a1=( ${b[0]} )
a2=( ${b[1]} )
If the array elements contain spaces, you will have to use a different delimiter when storing an array in the enclosing array.
|