af40908294
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@254 a672b425-5310-4d7a-af5c-997e18724b81
63 lines
1.3 KiB
HTML
63 lines
1.3 KiB
HTML
---
|
|
layout: page
|
|
author: Domenico Votta
|
|
category-page: advanced
|
|
category-title: Advanced commands
|
|
tags: compare sorted files
|
|
title: comm
|
|
previous-page: pages/cmd/advanced/colrm.html
|
|
next-page: pages/cmd/advanced/diff.html
|
|
---
|
|
The <code>comm</code> 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.<br>
|
|
|
|
Here we have two files named <code>example1.txt</code> and
|
|
<code>example2.txt</code> that contain 5 elements, to test this command:<br>
|
|
|
|
<code>example1.txt</code>
|
|
{% highlight bash %}
|
|
Icecream
|
|
Chocolate
|
|
Cake
|
|
Candy
|
|
Biscuit
|
|
{% endhighlight %}
|
|
|
|
<code>example2.txt</code>
|
|
{% highlight bash %}
|
|
Bread
|
|
Chocolate
|
|
Tomato
|
|
Candy
|
|
Pizza
|
|
{% endhighlight %}
|
|
|
|
The syntax command is:
|
|
<pre>
|
|
comm [flag][file1] [file2]
|
|
</pre>
|
|
|
|
<pre>
|
|
comm example1.txt example2.txt
|
|
Icecream
|
|
Chocolate
|
|
Cake
|
|
Tomato
|
|
Candy
|
|
Biscuit
|
|
Pizza
|
|
</pre>
|
|
|
|
<ul>
|
|
<li>The elements of the first file have less indentation.</li>
|
|
<li>The elements of the second file have some more indentation.</li>
|
|
<li>The elements in common have even more indentation than those of the second file.</li>
|
|
</ul>
|
|
|
|
<h3>Flags</h3>
|
|
|
|
<ul>
|
|
<li> <b>-1</b>: supress column 1</li>
|
|
<li> <b>-2</b>: supress column 2</li>
|
|
<li> <b>-3</b>: supress column 3</li>
|
|
</ul>
|