Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The Linux ps command allows multiple selectors, such as user and command name, but always returns the logical OR of those selectors (more than I want). Does anyone know of a method or tool already made that can get the intersection (AND) of process selectors?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Try pgrep. Different selectors there are AND connected. The same connectors can be used in either AND or OR syntax.

Example: pgrep -u user1,user2 -G 111 sshd will list sshd-processes that belong to user1 OR user2 AND are in group 111.

share|improve this answer
    
cool, I didn't know about that one, yet it was already on my system. Thanks! –  Keith Mar 28 '12 at 3:01
    
Dont mind - that is our age. ;-) pkill` is even more cool. –  Nils Mar 28 '12 at 20:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.