title: How to discover number of *logical* cores on Mac OS X?
body: <p>How can you tell, from the command line, how many cores are on the machine when you're running Mac OS X?  On Linux, I use:</p>
  
  <pre><code>x=$(awk '/^processor/ {++n} END {print n+1}' /proc/cpuinfo)
  </code></pre>
  
  <p>It's not perfect, but it's close.  This is intended to get fed to <code>make</code>, which is why it gives a result 1 higher than the actual number.  And I know the above code can be written denser in Perl or can be written using grep, wc, and cut, but I decided the above was a good tradeoff between conciseness and readability.</p>
  
  <p><strong>VERY LATE EDIT:</strong> Just to clarify: I'm asking how many <em>logical</em> cores are available, because this corresponds with how many simultaneous jobs I want <code>make</code> to spawn. jkp's answer, further refined by Chris Lloyd, was <em>exactly</em> what I needed. YMMV.</p>