comm Command: Tutorial & Examples

Compare two sorted files line by line

The comm command is a Linux utility that is used to compare two sorted files line by line. It takes two input files and produces three columns of output. The first column contains lines unique to the first file, the second column contains lines unique to the second file, and the third column contains lines that are common to both files.

The syntax for using the comm command is typically comm [options] file1 file2. If the input files are not already sorted, the comm command will not produce the expected output.

comm can be useful for comparing two files of data, finding the differences, and finding the commonalities between them. It's also useful when comparing two different versions of the same file.

It's important to note that comm compares only the lines, not the whole file or the content of the files.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA