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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -