How to compare multiple files in UNIX?

Hi,
I have below query related to multiple file comparing

I have four files i want to compare it and contents of one file will not be presence in 3other files and if any content found then it will print the execution.
Can you please help me how to achieve it.

Could you please provide us i/p file and desire output for better understanding ?

Consider like you have below four files:

file1.txt - 1 2 3
file2.txt - 4 5 6
file3.txt - 6 7 8 
file4.txt - 9 10 11
  1. Sort all the files using SORT
  2. Compare file1.txt and file2.txt using DIFF -- no contents were same, now merge these two files say new_file1.txt
  3. Compare new_file1.txt with file3.txt as like above -- one content is matched so it will return the value as '6', use SED / AWK to remove that value from file3.txt and merge the remaining contents with new_file1.txt
  4. Now finally, compare file4.txt with new_file1.txt -- no contents matched as per the example shown above.

You can try to code for above logic and still if you have doubts with the codes, provide your progress we can help you out.

This will work only if you're having limited no. of files, incase if you wanna to compare 40files then you will to try for various logic like using functions in shell scripting etc.