Tuesday, November 27, 2012

Compare two files using linux comm command

Comm Command: (to use this command file must b first sorted like cat file|sort > file1)
for Common : comm -1 -2 file1 file2
Ignore
-1 Ignore File1
-2 Ignore File1
-3 Ignore common data
Example:
File1
1
2
3
4
5

File2
3
4
5
6
7


comm -1 -2 file1 file2 => 3,4,5


comm -1 -3 file1 file2 => 6,7