Awk to the rescue.
ps -eo pid,args | awk '/PRD_/ && /startscen\.sh/ && $4 ~ /PROCESS_ALLBETS/'
(In the image, you have PROCESS_ALLBETS
, so I guess that's what you actually want, even though your text says PROCESS_ALL_BETS
.)
This selects for printing every line which matches all the following conditions:
/PRD_/
-- there is a "PRD_" somewhere in the line. Maybe you would tighten this to something like$6 ~ /^-NAME=PRD_/
to only match on the beginning of the sixth field./stratscen\.sh/
-- there is a match for this regex somewhere on the line. Again, for improved precision, you might want to change this to$3 ~ /startscen\.sh/
or even$3 == "startscen.sh"
if you only want exact matches.$4 ~ /PROCESS_ALLBETS/
-- the fourth field matches this regular expression.
The above will simply print all matching lines. To print just the first field and the eight field with the prefix -SESSION_NAME=
removed, add something like
{ n=$8; sub(/^-SESSION_NAME=/,"",n); print $1, n }
just before the closing single quote.