I would like to write a function in bash that takes two array parameters like this:
#!/bin/bash
function RemoveElements
{
# $1 and $2 are supposed to be arrays
# This function should generate a new array, containing
# all elements from $1 that did not occur in $2
}
a=(1 3 5 7 8)
b=(2 3 6 7)
c=RemoveElements $a $b
# or perhaps: (if directly returning non-integer
# values from function is not possible)
c=$(RemoveElements $a $b)
# c should now be (1 5 8)
Is this possible and if yes, what is the correct syntax? Both when calling the function, as well as inside the function to process the arrays?