How to merge two arrays in a zipper like fashion in Bash?

[*]

Assuming both arrays are the same size,

unset result
for (( i=0; i<${#array1[*]}; ++i)); do
    result+=( "${array1[$i]}" "${array2[$i]}" )
done

Leave a Comment