<p>From the man page "comm - compare two sorted files line by line"</p>
<p>It's part of the core utils package and you can install it using
<code>dnf install coreutils</code> on RPM distros, or
<code>apt install coreutils</code> on Debian based ones.</p>
<pre><code>[host@hpr]$ man comm

COMM(1)                               User Commands                              COMM(1)

NAME
       comm - compare two sorted files line by line

SYNOPSIS
       comm [OPTION]... FILE1 FILE2

DESCRIPTION
       Compare sorted files FILE1 and FILE2 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.

       -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)

       --check-order
              check that the input is correctly sorted, even if all input lines are pairable

       --nocheck-order
              do not check that the input is correctly sorted

       --output-delimiter=STR
              separate columns with STR

       --total
              output a summary

       -z, --zero-terminated
              line delimiter is NUL, not newline

       --help display this help and exit

       --version
              output version information and exit

       Note, comparisons honor the rules specified by &#39;LC_COLLATE&#39;.

EXAMPLES
       comm -12 file1 file2
              Print only lines present in both file1 and file2.

       comm -3 file1 file2
              Print lines in file1 not in file2, and vice versa.

AUTHOR
       Written by Richard M. Stallman and David MacKenzie.

REPORTING BUGS
       GNU coreutils online help: &lt;https://www.gnu.org/software/coreutils/&gt;
       Report any translation bugs to &lt;https://translationproject.org/team/&gt;

COPYRIGHT
       Copyright &#xA9; 2022 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later
       &lt;https://gnu.org/licenses/gpl.html&gt;.  This is free software: you are free to change and
       redistribute it.  There is NO WARRANTY, to the extent permitted by law.

SEE ALSO
       join(1), uniq(1)

       Full documentation &lt;https://www.gnu.org/software/coreutils/comm&gt;
       or available locally via: info &#39;(coreutils) comm invocation&#39;

GNU coreutils 9.1</code></pre>
<p>I always find that confusing, so for me it's a lot easier to see what
is going on by creating some example files.</p>
<p>First let's create some test files by echoing the number 1 and the
number 2 into a file called <code>1and2.txt</code></p>
<pre><code>[host@hpr]$ echo &quot;1&quot; &gt; 1and2.txt
[host@hpr]$ echo &quot;2&quot; &gt;&gt; 1and2.txt</code></pre>
<p>And let's create another one with the value 2 and 3 and we'll call it
<code>2and3.txt</code></p>
<pre><code>[host@hpr]$ echo &quot;2&quot; &gt; 2and3.txt
[host@hpr]$ echo &quot;3&quot; &gt;&gt; 2and3.txt</code></pre>
<p>Then we can see what each command does using these examples.</p>
<pre><code>[host@hpr]$ comm -1 -2 1and2.txt 2and3.txt
2
[host@hpr]$ comm -1 -3 1and2.txt 2and3.txt
3
[host@hpr]$ comm -2 -3 1and2.txt 2and3.txt
1
</code></pre>
