Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ comm(1) — OSF/1 X2.0-8 MIPS

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cmp(1)

ctab(1)

diff(1)

sdiff(1)

sort(1)

uniq(1)

ctab(4)

comm(1)  —  Commands

OSF

NAME

comm − Compares two sorted files

SYNOPSIS

comm [-123] file1 file2

The comm command reads file1 and file2 and writes three columns to standard output, showing which lines are common to the files and which are unique to each. 

FLAGS

-1Suppresses output of the first column (lines in file1 only). 

-2Suppresses output of the second column (lines in file2 only). 

-3Suppresses output of the third column (lines common to file1 and file2). 

comm -123 produces no output. 

DESCRIPTION

The leftmost column of standard output includes lines that are in file1 only.  The middle column includes lines that are in file2 only.  The rightmost column includes lines that are in both file1 and file2. 

If you specify - (dash) in place of one of the filenames, comm reads standard input. 

file1 and file2 should be sorted according to the collating sequence specified by the LC_COLLATE environment variable (see ctab and sort). 

EXAMPLES

In the following examples, file1 contains the following sorted list of North American cities:

Anaheim
Baltimore
Boston
Chicago
Cleveland
Dallas
Detroit
Kansas City
Milwaukee
Minneapolis
New York
Oakland
Seattle
Toronto

file2 contains this sorted list:

Atlanta
Chicago
Cincinnati
Houston
Los Angeles
Montreal
New York
Philadelphia
Pittsburgh
San Diego
San Francisco
St. Louis

     1.To display the lines unique to each file and common to the two files, enter:

comm file1 file2

This command results in the following output:

Anaheim
Atlanta
Baltimore
Boston
Chicago
Cincinnati
Cleveland
Dallas
Detroit
Houston
Kansas City
Los Angeles
Milwaukee
Minneapolis
Montreal
New York
Oakland
Philadelphia
Pittsburgh
San Diego
San Francisco
Seattle
St. Louis
Toronto

The leftmost column contains lines in file1 only, the middle column contains lines in file2 only, and the rightmost column contains lines common to both files. 

     2.To display any one or two of the three output columns, include the appropriate flags to suppress the columns you do not want.  For example, the command

comm -3 file1 file2

results in the following output:

Anaheim
Atlanta
Baltimore
Boston
Cincinnati
Cleveland
Dallas
Detroit
Houston
Kansas City
Los Angeles
Milwaukee
Minneapolis
Montreal
Oakland
Philadelphia
Pittsburgh
San Diego
San Francisco
Seattle
St. Louis
Toronto

     3.The following command:

comm -13 file1 file2

results in the following output:

Atlanta
Cincinnati
Houston
Los Angeles
Montreal
Philadelphia
Pittsburgh
San Diego
San Francisco
St. Louis

     4.The following command:

comm -12 file1 file2

results in the following output:

Chicago
New York

RELATED INFORMATION

Commands:  cmp(1), ctab(1), diff(1), sdiff(1), sort(1), uniq(1). 

Files:  ctab(4). 

OSF/1 User’s Guide. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026