Compare and Differentiate Multiple Files

Im using code below comparing and getting the diff of two files.
But what about multiple files? can you help me guys

diff -u file1 file2|sed -n '/^---/!{/^-/s/-//p}'
diff -ui file1 file2| sed -n '/^++/!{/^+/s/+//p}' 

Example
File1:

aaa
bbb
ccc
ddd

File2:

bbb
eee

File3:

bbb
ccc
ddd

Output.

File1 File2 File3 has bbb
File 1 doesnt have eee
File 2 doesnt aaa ccc ddd
File3 doesnt have aaa eee

Output:

Common Line bbb
etc etc . . .

Hello,

Could you please try following code.

awk 'FILENAME==ARGV[1] {a[$1]=$1;next} !($1 in a){p[$1 " NOT in file1"]=$1 " NOT in file1"} FILENAME==ARGV[2] {b[$1]=$1;next} !($1 in b) {p[$1 " NOT in file2"]= $1 " NOT in file2"} FILENAME==ARGV[3] {c[$1]=$1;next} !($1 in c){p[$1 " NOT in file3"]=$1 " NOT in file3"} FILENAME==ARGV[4] {d[$1]=$1;next} !($1 in d){p[$1 " NOT in file1"]=$1 " NOT in file1"} END{for(u in p){print p}}' file*

Output will be as follows.

aaa NOT in file2
aaa NOT in file3
eee NOT in file1
ddd NOT in file2
ccc NOT in file2

Thanks,
R. Singh

Hi Ravin,
Thank you, but i hope at least it will show what is the common line.
thanks

Try

echo common line: $(comm -12 file1 file2 | comm -12 - file3)
common line: bbb
coerdtr@RudisPC:/mnt/9/playground$ for i in 1 2 3; do echo file$i doesn\'t have $(sort -u file[1-3] | comm -23 - file$i); done
file1 doesn't have eee
file2 doesn't have aaa ccc ddd
file3 doesn't have aaa eee

Thanks guys...

You can identify identical files using cksum.

$ find topdir -type f | xargs cksum -n99 | sort | while read c s n
do
 if [ "$c $s" = "$csl" ]
  then
   echo "$csn$c $s $n"
   csn=''
  else
   csn="$c $s $n
"
  fi
 csl="$c $s"
done | pg