title: How to get process id from process name?
body: <p>I'm trying to create a shell script getting the <em>process id</em> of the Skype app on my Mac.</p>
  
  <blockquote>
    <p>ps -clx | grep 'Skype' | awk '{print $2}' | head -1</p>
  </blockquote>
  
  <p>The above is working fine, but there are two problems:</p>
  
  <p><strong>1)</strong>
  The <em>grep</em> command would get all process if their name just contains "Skype". How can I ensure that it only get the result, if the process name is exactly <em>Skype</em>?</p>
  
  <p><strong>2)</strong>
  I would like to make a shell script from this, which can be used from the terminal but the process name should be an argument of this script:</p>
  
  <pre><code>#!/bin/sh
  
  ps -clx | grep '$1' | awk '{print $2}' | head -1
  </code></pre>
  
  <p>This isn't returning anything. I think this is because the <em>$2</em> in the awk is treated as an argument too. How can I solve this?</p>