The comm is a command that compares two sorted files line by line and writes the output: the lines they have in common and the lines that are unique.
Here we have two files named example1.txt and example2.txt that each contain 5 elements, to test this command:
example1.txt
Icecream
Chocolate
Cake
Candy
Biscuit
example2.txt
Bread
Chocolate
Tomato
Candy
Pizza
The syntax command is:
comm [flag] [file1] [file2]
comm example1.txt example2.txt
    Icecream
        Chocolate
    Cake
      Tomato
        Candy
    Biscuit
      Pizza
  • The elements of the first file have less indentation.
  • The elements of the second file are more indented
  • The elements in common are even more indented than those of the second file.

Flags

  • -1: suppress column 1
  • -2: suppress column 2
  • -3: suppress column 3