This is probably a very simple question for an experienced person with UNIX, however I am trying to extract a number from a string and continue to get the wrong result.
This is the line:
8962 ? 00:01:09 java
This is the result I want
8962
But for some reason, I keep getting the exact same string. This is what I tried
pid=$(echo $str | sed "s/[^[0-9]{4}]//g")
If anyone can help me, this will be appreciated.
source
share