Is there anyway that I can compare two Arrays to see if any new strings have been added in them? eg:
Array 1: Joe Bob Jane
Array 2: Joe Bob Jane Greg
It would then output a new array with the changes:
Array 3: Greg
I'm not very good at shell scripting, and my google and forum searches have come up empty. I'd rather do the whole thing in bash, because this will be run on OSX, and you don't really get much else than bash unless you install developer tools, and the computers that I intend to use the script on will not have the develope tools.
This should only return the words in the second string that weren't in the first...
#!/usr/bin/bash
a1="Joe Bob Jane"
a2="Joe Bob Jack Jane Greg"
a3=$(printf "$a1\n$a2"|awk '{for(i=1;i<=NF;i++)if(NR==1)a[$i]=i;else if(!($i in a))print $i}')
echo $a3