Sort two files in Linux and find lines unique to each file
<p>I have 2 files.</p>

<p>File1 content looks like:</p>

<pre><code>000000513609200,238/PLMN/000100
000000513609200,238/PLMN/000200
000050354428060,238/PLMN/000200
000050354428060,238/PLMN/000100
001212131415120,238/PLMN/000100
...
...
</code></pre>

<p>File2 contents:</p>

<pre><code>000000513609200,238/PLMN/000100
000000513609200,238/PLMN/000200
000050354428060,238/PLMN/000200
000050354428060,238/PLMN/000100
001212131415120,238/PLMN/000100
...
...
</code></pre>

<p>File1 has close to 15000 records and file2 has close to 20000 records. I want to find the lines(records) present only in file1 or file2. I'm using the below:</p>

<pre><code>comm -3 &lt;(sort file1) &lt;(sort file2) &gt; file6
</code></pre>

<p>Is this a good option?</p>

<p>Also how exactly the sort works with these records ? How will it understand which column to take as primary key ?</p>

<p>Also can you suggest a simple awk script to do the comparison between file1 and file2 and forward the lines present either only in file1 or only in file2 to file7, so that I can compare the outputs. I want to make sure that my <code>comm</code> is yielding the same result.</p>