title: How can you write a while loop to run parallel processes on Unix ssh?
body: <p>I have a script file that contains different case IDs of a factorial Design of Experiment (DoE). I also have a script file run on MATLAB. I am attempting to run multiple cases of this DoE at once, 25 to be exact, and only up to 25 at once. The current input to the ssh server looks like the following (the batch file):</p>
  <pre><code>InputFile=inputfile.txt
  count=0
  while read -r case; do
  echo $case
  nohup matlab -nodisplay -nodesktop -r &quot;try;runinput=$case;matlab_script;end;exit&quot;
  ((++count % 25 == 0)) &amp;&amp; wait
  done &lt;&quot;$InputFile&quot;
  </code></pre>
  <p>This however, only reads the first line of the inputfile.txt and runs that, and does not run the other 24 processes at the same time. I have tried getting rid of the &amp;&amp; wait part but it still doesn't do what I want. How can I make it start the 24 other jobs in parallel?</p>