Pgrep

is a command-line utility initially written for use with the Solaris 7 operating system by Mike Shapiro. It has since been available in illumos and reimplemented for the Linux and BSDs (DragonFly BSD, FreeBSD, NetBSD, and OpenBSD). It searches for all the named processes that can be specified as extended regular expression patterns, and—by default—returns their process ID. Alternatives include  (finds process ID given a program name) and.

Example usage
The default behaviour of  (returning the process identifier of the named tasks) simplifies an otherwise complex task and is invoked with:

Which is roughly equivalent to:

Additional functionality of  is listing the process name as well as the PID ( -l Lists the process name as well as the process ID) of all processes belonging to the group   ( -G Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used):

showing all processes that do not belong to the user  ( -u euid Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used) by inverting the matching ( -v Negates the matching):

and only matching the most recently started process ( -n Select only the newest (most recently started) of the matching processes):