title: Intersection between text files
body: <p>How can I compute the intersection between two text files in terms of raw text? It doesn't matter whether the solution uses a shell command or is expressed in Python, Elisp, or other common scripting languages.</p>
  
  <p>I know <code>comm</code> and <code>grep -Fxv -f file1 file2</code>. Both assume that I am interested in the intersection of <em>lines</em>, whereas I am interested in the intersection of <em>characters</em> (with a minimum on the number of characters necessary to count as a match).</p>
  
  <p>Bonus points for efficiency.</p>
  
  <p><strong>Example</strong></p>
  
  <p>If file 1 contains</p>
  
  <pre><code>foo bar baz-fee
  </code></pre>
  
  <p>and file 2 contains</p>
  
  <pre><code>fee foo bar-faa
  </code></pre>
  
  <p>then I would like to see</p>
  
  <ul>
  <li><code>foo bar</code></li>
  <li><code>fee</code></li>
  </ul>
  
  <p>assuming a minimum match length of 3.</p>