title: Running parallel commands in bash
body: <p>I have a situation where I have a directory "batches" containing several batch files:</p>
  
  <pre><code>one.txt
  two.txt
  ...
  seventy.txt
  </code></pre>
  
  <p>Each of these files needs to be processed by a python script as:</p>
  
  <pre><code>python processor.py --inputFile=batches/one.txt
  </code></pre>
  
  <p>My current implementation is as such:</p>
  
  <pre><code>for f in batches/$f
  do
  python processor.py --inputFile=batches/$f
  done
  </code></pre>
  
  <p>I have hundreds of batches, so running all of them in parallel as</p>
  
  <pre><code>python processor.py --inputFile=batches/$f &amp;
  </code></pre>
  
  <p>Is not feasible.</p>
  
  <p>However,I think that running ~10 at a time shouldn't be a problem.</p>
  
  <p>I'm aware that the syntax</p>
  
  <pre><code>{
  python processor.py --inputFile=batches/batchOne.txt
  python processor.py --inputFile=batches/batchTwo.txt
  } &amp;
  {
  python processor.py --inputFile=batches/batchThree.txt
  python processor.py --inputFile=batches/batchFour.txt
  }
  </code></pre>
  
  <p>Should give me a result similar to the one I wanted. However, are there any better solutions? Basically, given a command template, in my case</p>
  
  <pre><code>python processor.py --inputFile=batches/$1
  </code></pre>
  
  <p>And a list of batches, I'd like to control how many get executed at the same time.</p>
  
  <p>I'm working on Ubuntu Linux.</p>