comm
Compare two sorted files line by line.
General
Without any options provided, a three column output will be produced.
Column one contains lines unique to file1, column two contains lines unique to file2, and column three contains lines common to both files.
To suppress a column, provide either -1, -2 or -3 as option.
Can be used with sort like so in case input files aren't sorted beforehand
comm <(sort file1) <(sort file2)Examples
Print only the column with common lines
comm -12 file1 file2Print two columns, where the first column is lines unique to file1 and the second is lines unique to file2.
comm -3 file1 file2Print lines unique to file1
comm -23 file1 file2Print lines unique to file2
comm -13 file1 file2Reference
Last updated