I\'m trying to loop through an array that contains other arrays and these arrays consist of strings with spaces. The problem is that I can\'t seem to preserve the spacing in the
Replace eval
with indirect parameter expansion, and you'll get what I think you want (although it doesn't match your current given output:
for high_item in "${high[@]}"
do
arrayz="$high_item[@]"
# arrayz is just a string like "low1[@]"
for item in "${!arrayz}"
do
echo $item
done
done
Note the need to quote the array expansion in the inner loop to preserve the whitespace in elements of low1
.