UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: combChapter 2
UNIX Commands
Next: Reference: compress
 

comm

comm [options] file1 file2

Compare lines common to the sorted files file1 and file2. Three-column output is produced: lines unique to file1, lines unique to file2, and lines common to both files. comm is similar to diff in that both commands compare two files. But comm can also be used like uniq; that is, comm selects duplicate or unique lines between two sorted files, whereas uniq selects duplicate or unique lines within the same sorted file.

Options

-

Read the standard input.

-1

Suppress printing of column 1.

-2

Suppress printing of column 2.

-3

Suppress printing of column 3.

-12

Print only lines in column 3 (lines common to file1 and file2).

-13

Print only lines in column 2 (lines unique to file2).

-23

Print only lines in column 1 (lines unique to file1).

Example

Compare two lists of top-ten movies, and display items that appear in both lists:

comm -12 siskel_top10 ebert_top10


Previous: Reference: combUNIX in a Nutshell: System V EditionNext: Reference: compress
Reference: combBook IndexReference: compress

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System