Skip to main content

UNIX: comm = diff - formatting

The comm utility reads file1 and file2, which should be sorted lexically, and produces three text columns as output: lines only in file1; lines only in file2; and lines in both files. It's sort of twist on diff. It's nice because there's no formatting to get in the way.
$ cat > 1.txt << __END__                                 
1
2
3
__END__
$ cat > 2.txt << __END__
heredoc> 2
heredoc> 3
heredoc> 4
heredoc> __END__
$ comm 1.txt 2.txt
1
2
3
4
Thanks to Krishna Srinivasan for teaching me about a new old-school tool ;)

Comments