|
|
|
|
|
by gwu78
3335 days ago
|
|
Example line from the Openshift reload-haproxy script: old_pids=$(ps -A -opid,args | grep haproxy | egrep -v -e 'grep|reload-haproxy' | awk '{print $1}' | tr '\n' ' ')
Can we do this without grep, egrep and awk?
Would this work? old_pids=$(exec ps -A -opid,args |sed -n '/sed/d;/reload-haproxy/d;/haproxy/{s/ .*//;p};'|tr '\n' ' ')
|
|
If you still want grep, without it matching itself, an old trick is egrep '[h]aproxy' or similar.
Egrep, as opposed to pgrep, is more widely installed on non Linux systems like osx.