Sunday, March 18, 2018

Comparing two files without using DIFF


This is a a short way to compare 2 files on a Unix box without using DIFF. You can remove the option to output it to a file "> file3" if you want to see the output first.



If you want to see the uniq entries without the duplicates then output to a file:

Command:

sort file1 file2 | uniq -u > file3



If you want to see just the duplicate entries use "uniq -d" option then output to a file:

Command:

sort file1 file2 | uniq -d > file3