comm (compare two sorted text files)

Compares two sorted text files. Displays the results in three columns: 1) lines that are only in file1, 2) lines that are only in file2, and 3) lines that are in both files.

Format:    comm file1 file2
Examples:  comm  report1  report2

The differences are displayed, as shown below.

					cat report1
Apples
Peaches
Pears
cat report2
Apples
Cherries
Pears
comm report1 report2
                                   Apples
Peaches
                Cherries
                                    Pears

The output shows Apples and Pears in both files. It shows Peaches only in the first file and Cherries only in the second file.

Get Spring Into Linux® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.