(no title)
gwu78 | 8 years ago
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' ' ')
tyingq|8 years ago
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.
ploxiln|8 years ago
gwu78|8 years ago
I see this usage often where it seems like
can be replaced by or at least or But I must be missing something obvious.For example look at the "grep -v" usage here:
https://github.com/thomwiggers/qhasm/raw/master/qhasm-arm
Is there something wrong with using
Moreover, in the last line, why not use instead of Apologies if I am missing the obvious.gnaritas|8 years ago
vbernat|8 years ago