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.
This is the string:
8962 ? 00:01:09 java
This it the output I want
8962
But for some reason I keep getting the same exact string back. This is what I've tried
pid=$(echo $str | sed "s/[^[0-9]{4}]//g")
If anybody could help me out it would be appreciated.