My first post here, lets see how this goes.
Working on an issue where I have multiple "host lists". one set for linux, one for windows, one for printers.
I also have a list of what is currently being monitored.
I have been working on some code to try and unify the host lists and then get a diff of that list and the current monitoring list.
I found some good code I found on here:
Array1=( "key1" "key2" "key3" "key4" "key5" "key6" "key7" "key8" "key9" "key10" )
Array2=( "key1" "key2" "key3" "key4" "key5" "key6" )
Array3 =diff(Array1, Array2)
Array3 ideally should be : Array3=( "key7" "key8" "key9" "key10" )
This gives me the list of what needs to be added and works incredibly well.
Lets assume that Array2 contained an element whose value was "key11"
If I use the same diff I get all of the previous values AND key11.
Array1=( "key1" "key2" "key3" "key4" "key5" "key6" "key7" "key8" "key9" "key10" )
Array2=( "key1" "key2" "key3" "key4" "key5" "key6" "key11")
Array3 =diff(Array1, Array2)
this outputs key 11 key10 .....
I guess I need to do two things:
a list of all things that 1!=2 but NOT 2!=1
a list of all things that 2!=1 but NOT 1!=2
I am hoping to account for the fact that these are being filled from a CSV whose content I do not control and the variation of naming conventions for each of the host lists means that the order/number/etc of the arrays will be unknown. How would I do that? I can see the logic for this just not the code. Any help is tremendously appreciated. Please save me from agonizing over this all weekend.