Get process list with logical intersection of selectors

processpssearch

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?

Best Answer

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.

Related Question