This question refers to the answered question: Compare/Difference of two arrays in bash
Let's take two arrays:
Array1=( "key1" "key2" "key3" "key4" "key5" "key6" "key7" "key8" "key9" "key10" "key13" )
Array2=( "key1" "key2" "key3" "key4" "key5" "key6" "key11" "key12" "key13" )
Symetrical Differences between arrays:
Array3=(`echo ${Array1[@]} ${Array2[@]} | tr ' ' '\n' | sort | uniq -u `)
Array3 values:
echo $Array3
key10
key11
key12
key7
key8
key9
Values only in Array1:
echo ${Array1[@]} ${Array3[@]} | tr ' ' '\n' | sort | uniq -D | uniq
key10
key7
key8
key9
Values only in Array2
echo ${Array2[@]} ${Array3[@]} | tr ' ' '\n' | sort | uniq -D | uniq
key11
key12
My question, how can we get values that are in Array1 & Array2 but not in Array3 (identical)? Expected result:
key1
key13
key2
key3
key4
key5
key6
Thanks for your help.