Combine arrays first:
arr3=("${arr1[@]}" "${arr2[@]}")
Then apply the solution from this for deduplication:
# Declare an associative array declare -A arr4 # Store the values of arr3 in arr4 as keys. for k in "${arr3[@]}"; do arr4["$k"]=1; done # Extract the keys. arr5=("${!arr4[@]}")
This assumes bash 4+.
Steven
source share