Shell script to compare two files for duplicate..??

Hi ,
I had a requirement to compare two files whether the two files are same or different .... like(files contaisn of two columns each)

file1.txt

121343432213 1234
64564564646 2345
343423424234 2456

file2.txt

121343432213 1234
64564564646   2345
31231313123   3455

how to compare two above files to make sure that whether the two files are same or different....?

thanks in advance

hemanthsaikumar.

Hello hemanthsaikumar,

Following may help you in same.

awk -F" " 'FNR==NR{A[$1 OFS $2];next} !($1 OFS $2 in A){X++} END{if(!X){print "No differances."} else {print "Differances found in files."}}' file1 file2

Output will be as follows for provided input by you.

Differances found in files.

Thanks,
R. Singh

If the files are ordered:

diff -w file1 file2

or:

comm -3 file1 file2

although the latter doesn't ignore differences in whitespaces.