All pastes #221219 Raw Edit

Anonymous

public text v1 · immutable
#221219 ·published 2006-10-25 15:43 UTC
rendered paste body

array1=(bob john mary)
array2=(bob john fred george)
for i in ${!array1[@]}; do
    if ! grep -q ${array1[i]} <<<${array2[@]}; then
        diff12[i]=${array1[i]}
    fi
done
for i in ${!array2[@]}; do
    if ! grep -q ${array2[i]} <<<${array1[@]}; then
        diff21[i]=${array2[i]}
    fi
done

echo ${diff12[@]} not in array2
echo ${diff21[@]} not in array1
# output
# mary not in array2
# fred george not in array1