I want to compare the below arrays and print/store only the dissimilar items in another array. can you pls help.
eg Array1 for :
20150313 20150324 20150325 20150326 20150330 20150331 20150401 20150402 20150403 20150406 20150407 20150408 20150409 20150410 20150413 20150414 20150415 20150416 20150417 20150418 20150420 20150421 20150422 20150423 20150424 20150427 20150428
eg Array 2 for :
20150313 20150323 20150324 20150325 20150326 20150327 20150330 20150331 20150401 20150402 20150403 20150406 20150407 20150408 20150409 20150410 20150413 20150414 20150415 20150416 20150417 20150418 20150420 20150421 20150422 20150423 20150424 20150427 20150428 20150313 20150323 20150324 20150325 20150326 20150327 20150330 20150331 20150401 20150402 20150403 20150406 20150407 20150408 20150409 20150410 20150413 20150414 20150415 20150416 20150417 20150418 20150420 20150421 20150422 20150423 20150424 20150427 20150428
if i try this in bash, it only prints the values in array 1
Array3=()
$ for i in "${Array1[@]}"; do
> skip=
> for j in "${Array2[@]}"; do
> [[ $i == $j ]] && { skip=1; break; }
> done
> [[ -n $skip ]] || Array3+=("$i")
> done
pls assist.
a1[i]toa2[i], cause offsets are possible. An easy way I can think of would be to put them in textual variables with values separated by newlines, and usediffto compare them. However, if the order doesn't matter and only the existence of elements matter, i wouldsort-uniqfirst.