Is it possible to take the difference of two arrays in Bash. What is a good way to do it?
Code:
Array1=( "key1" "key2" "key3" "key4" "key5" "key6" "key7" "key8" "key9" "key10" )
Array2=( "key1" "key2" "key3" "key4" "key5" "key6" )
Array3 =diff(Array1, Array2)
Array3 ideally should be :
Array3=( "key7" "key8" "key9" "key10" )
echo ${Array1[@]} ${Array2[@]} | tr ' ' '\n' | sort | uniq -u
Output
key10
key7
key8
key9
You can add sorting if you need