linux - bash out processes from a range -
i need out number of working processes identifiers lying in specific range. example, have 3 processes pids: 125, 200, 450. need command like(pseudo-code) -
top -r 100-300
i want see in output
2
it sum of 2 processes pids 125 , 200. cannot understand, how can of 'ps' , 'top' commands. maybe there other commands? or job can done these commands?
thanks!
you can use awk this:
ps | awk '($1>=lo)&&($1<=hi){n++}end{print n}' replace lo lower limit (100) , hi upper limit (300).
or may away if range small enough:
ps -h -p {100..300} | wc -l
Comments
Post a Comment