comm

>Usage

The comm command is used to compare two sorted files line by line and display differences and similarities. It outputs three columns: lines unique to the first file, lines unique to the second file, and lines common to both files.

>Syntax

comm [options] file1 file2

>Options

-1

Suppresses the first column (unique to file1).

-2

Suppresses the second column (unique to file2).

-3

Suppresses the third column (common lines).

>Examples

Example 1:

Dots

-zsh

> comm file1.txt file2.txt


apple (lines only in file1)
kiwi (lines only in file2)
pear
banana (lines common in file1 and file2)
grape
orange

Example 2:

Dots

-zsh

> comm -23 file1.txt file2.txt


apple (display lines unique to file1)
orange

Example 3:

Dots

-zsh

> comm -12 file1.txt file2.txt


banana (display lines common of both files)
grape

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Gokhan YILMAZ