title: Parallelise grep - use file rows as input for grep
body: <p>I have <code>File1</code> and <code>File2</code> as below. I found similar questions but not quite the same.</p>
  
  <p>Use <code>File1</code> rows as input for <code>grep</code> and extract 1st column of <code>File2</code>. In below toy example, if column2 in <code>File2</code> equals to <code>a</code> or <code>b</code> then write <code>1</code> to <code>File_ab</code>.</p>
  
  <p>So far I am using double loop, and estimated time is 4 days. I was hoping to get something like: <code>cat File1 | xargs -P 12 -exec grep "$1\|$2" File2 &gt; File_$1$2.txt</code>
  But failed to get the syntax right. I am trying to run 12 <code>greps</code> in parallel with <code>OR</code> condition.</p>
  
  <pre><code>File1
  a b
  c d
  
  File2
  1 a
  2 b
  3 c
  1 d
  4 a
  5 e
  6 d
  </code></pre>
  
  <p>Desired output is 2 files, File_ab and File_cd:</p>
  
  <pre><code>File_ab
  1
  2
  4
  File_cd
  1
  3
  6
  </code></pre>
  
  <p><strong>Note:</strong> My <code>File1</code> is 25K rows, and <code>File2</code> is 10Mln rows.</p>