title: slurm: Is there any way to return unused core number?
body: <p>As we know <code>squeue</code> returns the status of the running jobs.</p>
  
  <pre><code>squeue
           JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
             130     debug   run.sh    user PD       0:00      1 (Resources)
             131     debug   run.sh    user PD       0:00      1 (Resources)
             128     debug 52546914    user  R       7:28      1 node1
             129     debug   run.sh    user  R       0:02      1 node1
  </code></pre>
  
  <p>For example my core number is 2. </p>
  
  <p><strong>[Q]</strong> Is there any way to return only the unused core number? In the example, unused core number should return 0. </p>
  
  <p>Should I write a parser for this in order to retrieve core number next to each <code>R</code>, add them, and subtract it from total core number as follows:</p>
  
  <pre><code>squeue | grep -P ' R       ' | awk '{print $7}' | paste -sd+ - | bc
  </code></pre>