Reputation: 14108
Suppose I have two arrays where:
a[i] = "space separated string"
b[i] = "22"
I want to make a third array so that:
c[i]= "${a[i]} ${b[i]}} #appending two string with space between them.
Is it possible without loops?
Upvotes: 0
Views: 75
Reputation: 33317
This is probably the most inefficient way to do it, but here it is without loops:
IFS=$'\n' c=($(paste -d ' ' <(printf "%s\n" "${a[@]}") <(printf "%s\n" "${b[@]}")))
Of course it only works if there are no newlines in the array elements
Upvotes: 2