to compare two files and to print the difference

suppose one file
P1168S
P2150L
P85L
Q597R
R1097C

Another file
P2150L
P85L
Q597R
R1097C
R1379C
R1587K

Then output shud be
R1379C
R1587K

thanks

Why not P1168S - it is not in "another file"

use cmp file1 file2
or
diff file1 file2

what exactly are you looking for?

cheers,
Devaraj Takhellambam

yah ....
u have a file1 and file2 then contents not found in file 2 shud be displayed

Use this...Please note that this will work for sorted files

comm -23 file1 file2
awk 'BEGIN { while ( getline < "firstfile" ) { arr[$0]++ } } { if (!( $0 in arr ) ) { print } }' secondfile