pgrep

from Wikipedia, the free encyclopedia

pgrep is a command line program that was originally developed for the Solaris 7 operating system. Since then, however, a version for GNU / Linux and OpenBSD has also been written. The program searches for all named processes that can be specified as regular expressions and returns their process ID by default. Alternatives include pidof , which was originally developed for Linux, and ps . pgrep per se is a simplified notation of a more complex chain of program calls in order to simplify input. However, it was also expanded to include its own functionality in order to be able to execute more complex queries for processes.

Examples

Basic functionality

  • The ID of a process is output with the following call:
pgrep prozessname
  • This is largely equivalent to the following call:
ps ax | grep prozessname | grep -v grep | awk '{print $1}'

Extended functionality

  • Show all processes (with name and ID) belonging to the group other :
pgrep -l -G other
  • Show all processes that do not belong to the root user :
pgrep -v -u root

Web links