title: adb: Find PID from the adb shell
body: <p>I am trying to get the PID of the process INSIDE adb shell. So, I am doing adb shell which gets me to the android shell. Now, if I were to get the PID using a regular shell I would use </p>
  
  <pre><code>adb shell ps | grep android.process.acore | sed 's/\s\s*/ /g' | cut -d ' ' -f 2
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>adb shell ps | grep android.process.acore | awk '{ print $2 }'
  </code></pre>
  
  <p>I get the PID (a numeric number - 2nd field of the <code>ps | grep android.process.acore</code>) output.</p>
  
  <p>However, if I run the above commands inside android shell(after doing <code>adb shell</code>), I get <code>/system/bin/sh: sed: not found</code> and <code>/system/bin/sh: awk: not found</code> errors respectively. Which means, these commands are not available inside adb shell. However, grep works.</p>
  
  <p>The output of the <code>ps | grep android.process.acore</code> inside <code>adb shell</code> is:</p>
  
  <pre><code>XXX_x21   11826 441   502296 39028 ffffffff 4010ff6c S android.process.acore
  </code></pre>
  
  <p>I am looking for the number 11826.
  How can I extract it inside <code>adb shell</code>?</p>
  
  <p>Also, please help if there is a direct way to get the PID inside the adb shell.</p>
  
  <p>Regards,
  Rumit</p>