file comparing script

Hi Guys,

I need a help in putting a script which compares 2 files which has some names on it. I would like to compare both the files and put the common ones in another file, could anyone help me how to do that?

Also I want to do the same for 3 files also? I am a beginner in the scripting and any help would be greatly appreciated.

Regards,

RR

Look at man comm
comm

Thanks So much. It just works as what i was expecting for 2 files. Thanks for letting me know this command.

But I am unable to use 3 files. is there anyway I can compare 3 files ?

ex :

File 1
******
a
b
c
d

File 2
*******
a
c
d

File 3
******
a
b
c
d

Output :
********
a
c
d

There is a EXAMPLES section in man page of comm.
That has exactly what you want. Get common data for 3 files.
Idea is, pipe the output of 2 files to the 3rd file.
Pls try. If you get further problem, will give the command.

grep -f <(grep -f file1 file2 ) file3