title: UNIX BASH: extracting number from string
body: <p>This is probably a very simple question to an experienced person with UNIX however I'm trying to extract a number from a string and keep getting the wrong result.</p>
  
  <p>This is the string:</p>
  
  <pre><code>8962 ? 00:01:09 java
  </code></pre>
  
  <p>This it the output I want</p>
  
  <pre><code>8962
  </code></pre>
  
  <p>But for some reason I  keep getting the same exact string back. This is what I've tried </p>
  
  <pre><code>pid=$(echo $str | sed "s/[^[0-9]{4}]//g")
  </code></pre>
  
  <p>If anybody could help me out it would be appreciated.</p>