title: bash: Difference between join and comm
body: <pre><code># comm -12 /tmp/src /tmp/txt | wc -l
    10338
  # join /tmp/src /tmp/txt | wc -l
    10355
  </code></pre>
  
  <p>Both the files are single columns of alphanumeric strings and <code>sort</code>-ed. Shouldn't they be the same?</p>
  
  <hr>
  
  <p>Updated following @Kevin-s answer below:</p>
  
  <pre><code>cat /tmp/txt | sed 's/^[:space:]*//' &gt; /tmp/stxt
  cat /tmp/src | sed 's/^[:space:]*//' &gt; /tmp/ssrc
  </code></pre>
  
  <p>and the result:</p>
  
  <pre><code>#join /tmp/ssrc /tmp/stxt | wc -l
  516
  # comm -12 /tmp/ssrc /tmp/stxt | wc -l
  513
  </code></pre>
  
  <p>On manual inspection of the <code>diff</code>-s ... the results differ due to some whitespaces that were not taken out by the <code>sed</code>. </p>