Within a bash script, I am building two dynamic arrays. And I want to construct another array with difference of two.
Example:
array1=("aa-1234|safsf|sfsfs" "aa-2345|sfsfs|n0sfm" "aa-0890|ssfsf|sfss" "aa-8097|fsfsf|fsfs" "bb-1234|xvxx|xvxv" "cc-1234|jmsf|sfsfs" "cc-1235|xvxv|xvxv")
array2=(aa-1234 aa-8097)
array1 elements are long entries with |
as a delimiter in each.
Now I want to construct an array3, whose elements are all of array1 except those matching in array2.
I tried a for
loop to skip through elements. However array1 being a long one, it too much time. I'm looking for a more efficient way.