title: Using Xargs max-procs with multiple arguments from a file
body: <p>I have a script that is getting me the results I want. I want to improve the performance of the script.</p>
  
  <p>My script takes argument from file <code>file1.txt</code>.</p>
  
  <p>The contents are below:</p>
  
  <pre><code>table1
  table2
  table3
  and so on
  </code></pre>
  
  <p>Now when I use the <code>while</code>  statement like below the script runs in sequential order.</p>
  
  <p><code>while</code> statement is below:</p>
  
  <pre><code>while IFS=',' read -r a; do import.sh "$a"; done &lt;  file1.txt
  </code></pre>
  
  <p>Now when I use the <code>xargs</code> <code>max-procs</code> utility in bash then the scripts run in parallel based on no of max-procs.</p>
  
  <p><code>xargs</code> statement is below:</p>
  
  <pre><code>xargs --max-procs 10 -n 1 sh import.sh &lt;  file1.txt
  </code></pre>
  
  <p>Now I have another script   </p>
  
  <p>This script takes arguments from file <code>file2.txt</code>.</p>
  
  <p>The contents are below:</p>
  
  <pre><code>table1,db1
  table2,db2
  table3,db3
  and so on
  </code></pre>
  
  <p>when I use the <code>while</code> statement the script performs fine.</p>
  
  <pre><code>while IFS=',' read -r a b; do test.sh "$a" "$b"; done &lt;  file2.txt
  </code></pre>
  
  <p>But when I use teh <code>xargs</code> statement then the script gives me <code>usage</code> error.</p>
  
  <p><code>xargs</code> statement is below.</p>
  
  <pre><code>xargs --max-procs 10 -n 1 sh test.sh &lt;  file2.txt
  </code></pre>
  
  <p>The <code>error</code> statement is below:</p>
  
  <pre><code>Usage : test.sh input_file
  </code></pre>
  
  <p>Why is this happening?</p>
  
  <p>How can I rectify this?</p>