---
layout: page
author: Domenico Votta
category-page: advanced
category-title: Advanced commands
tags: compare sorted files
title: comm
---
The comm
is a command that compares two sorted files line by line and writes the output: the lines that are in common and the lines that are unique.
Here we have two files named example1.txt
and
example2.txt
that contain 5 elements, to test this command:
example1.txt
{% highlight bash linenos %}
Icecream
Chocolate
Cake
Candy
Biscuit
{% endhighlight %}
example2.txt
{% highlight bash linenos %}
Bread
Chocolate
Tomato
Candy
Pizza
{% endhighlight %}
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 doesn't have the tab.
The elements of the second file have one tab.
The elements in common have two tabs.