Often you may want to concatenate multiple arrays together into one array in Bash.
You can use the following syntax to do so:
array3+=( "${array1[@]}" "${array2[@]}" )
This particular example will concatenate the arrays named array1 and array2 together into a new array named array3.
The following example shows how to use this syntax in practice.
Example: How to Concatenate Arrays in Bash
Suppose that we create two arrays in Bash named array1 and array2 that both contain the names of various basketball teams:
array1=(Mavs Spurs Rockets Warriors)
array2=(Heat Magic Nets Celtics)
We can use the following syntax to concatenate these two arrays together into a new array named array3:
array3+=( "${array1[@]}" "${array2[@]}" )
We can then use the following syntax to view each of the elements in the new array named array3:
echo "${array3[@]}"
The following screenshot shows how to use this syntax in practice:

Notice that the new array named array3 contains all of the elements from the both array1 and array2.
We can also use the following syntax to view the total length of the new array:
echo ${#array3[@]}
The following screenshot shows how to use this syntax in practice:

This returns a value of 8, which tells us that the new concatenated array named array3 contains 8 total elements.
We can verify that this is correct by observing that array1 had 4 elements and array2 had 4 elements. When concatenated together, the new array has 8 total elements.
Related Tutorials
The following tutorials explain how to perform other common tasks in Bash:
Bash: How to Split a String into an Array
Bash: How to Remove Last Element from Array
Bash: How to Find Minimum and Maximum Values in Array
