Scroll to navigation

comm(1) General Commands Manual comm(1)

NAME

comm - Compare two sorted files line by line.

When FILE1 or FILE2 (not both) is -, read standard input.

With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.

SYNOPSIS

comm [-1 ] [-2 ] [-3 ] [--output-delimiter] [-z|--zero-terminated] [--total] [--check-order] [--nocheck-order] [-h|--help] [-V|--version] <FILE1> <FILE2>

DESCRIPTION

Compare two sorted files line by line.

When FILE1 or FILE2 (not both) is -, read standard input.

With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files.

OPTIONS

-1
suppress column 1 (lines unique to FILE1)
-2
suppress column 2 (lines unique to FILE2)
-3
suppress column 3 (lines that appear in both files)
separate columns with STR
line delimiter is NUL, not newline
output a summary
check that the input is correctly sorted, even if all input lines are pairable
do not check that the input is correctly sorted
Print help
Print version
<FILE1>

<FILE2>

VERSION

v(uutils coreutils) 0.7.0

EXAMPLES

Produce three tab-separated columns: lines only in first file, lines only in second file, and common lines:

comm file1 file2

Print only lines common to both files:

comm -12 file1 file2

Print only lines common to both files, reading one file from `stdin`:

cat file1 | comm -12 - file2

Get lines only found in first file, saving the result to a third file:

comm -23 file1 file2 > file1_only

Print lines only found in second file, when the files aren't sorted:

comm -13 <(sort file1) <(sort file2)

The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.

comm (uutils coreutils) 0.7.0