Using Diff to compare 2 arrays

I have two arrays and they look like this:

 array=(`cat /local/mnt/*sys/*includes|grep -v NEW`) 
array2=(`cat /tmp/*sys.z |grep -v NEW`)

I am trying to compare them but I need to use the diff -u command. I am not sure how to do this. I cannot just do

 diff  -u ${array[@]} ${array2[@]}

I cannot do "for i in" as there are two arrays. I did not want to use the test format, but the diff -u command. Any suggestions?

You use diff on files, not strings.

You can try this:

diff <(cat /local/mnt/*sys/*includes|grep -v NEW) <(cat /tmp/*sys.z |grep -v NEW)

when I run that command that Corona suggested, I get "diff: 2 filename arguments required" as I do with every attempt to use diff for these filelists.

It certainly doesn't do that for me. Can you show me exactly what you're doing, word for word, letter for letter, keystroke for keystroke? And what shell you're using?

Your last question, where you mention please let me know "letter by letter" how you typed the command made me think that my typing was bad. I found that the second cat statement did not have a space. Putting a space made it work.

)   <(cat /tmp/

instead of

) <(cat /tmp/
1 Like