1

I need help with bash. I have two array:

Array1=(1 2 3 4 5 6 7)
Array2=(2 5 7)

I need remove items from array1 which are in Array2. Result should be

Array3=(1 3 4 6).

5
  • read the answers in referenced questions. Commented Aug 16, 2017 at 13:25
  • I can see another similar question here. stackoverflow.com/questions/2312762/… Commented Aug 16, 2017 at 13:33
  • It's not quite a duplicate, but BashFAQ #36 is also relevant. Commented Aug 16, 2017 at 16:40
  • One should also consider using associative arrays to avoid the need to recurse -- the O(n*m) performance characteristics of the code given in the self-answer is really quite horrid. Commented Aug 16, 2017 at 16:41
  • Aside: Answering your own question is welcome here, but answering your own question by editing that answer into the question itself is not. This "privileges" answers, such that they can't be voted or commented on separate from the question itself, and prevents mechanisms for putting good answers first from being effective. Commented Aug 16, 2017 at 16:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.