I have to extract a certain port number piped from a process status (ps) command and am not quite sure how to get it.
For example, if I had this line (ps -ef | grep “blahblahblah”):
xxremote -xcom.xx.management.xremote.port=9999 -xcom.xx.management.xxxremote.ssl=false
How can I extract the number “9999”? NOTE: This is one part of a very LONG line, and I cannot use, for example, awk, to count how many fields after the “=” sign. The number of = signs will change.
I tried using the cut command but I only know how to use it with single character delimiters which isn’t what I need. I was thinking maybe awk or sed would do the trick? I am not to familiar with them. Thank you very much for the help
ps -ef | grep “blahblahblah” ” | awk …. (or sed)
UPDATE: Clarified that the port number needs to be extracted form a single long line of text, and that using an awk command is not required.
1 Answer