I have the following situation, two arrays, let\'s call them A( 0 1 ) and B ( 1 2 ), i need to combine them in a new array C ( 0:1 0:2 1:1 1:2 ), the latest bit i\'ve come u
Since Bash supports sparse arrays, it's better to iterate over the array than to use an index based on the size.
a=(0 1); b=(2 3) i=0 for z in ${a[@]} do for y in ${b[@]} do c[i++]="$z:$y" done done declare -p c # dump the array
Outputs:
declare -a c='([0]="0:2" [1]="0:3" [2]="1:2" [3]="1:3")'