HOME

TheInfoList



OR:

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 Illumos (stylized as "illumos") is a partly free and open-source Unix operating system. It has been developed since 2010 and is based on OpenSolaris, after the discontinuation of that product by Oracle. It comprises a kernel, device driver ...
and reimplemented for the
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
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 pidof (finds process ID given a program name) and ps.


Example usage

The default behaviour of pgrep (returning the
process identifier In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernel (operating system), kernels—such as those of Unix, macOS and Windows—to uniquely identify an active Process (computing), process. ...
of the named tasks) simplifies an otherwise complex task and is invoked with: $ pgrep 'bash' Which is roughly equivalent to: $ ps ax , awk ' $5 ~ /bash/ ' Additional functionality of pgrep 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 alice (-G Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used): $ pgrep -l -G alice showing all processes that do not belong to the user
root In vascular plants, the roots are the plant organ, organs of a plant that are modified to provide anchorage for the plant and take in water and nutrients into the plant body, which allows plants to grow taller and faster. They are most often bel ...
(-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): $ pgrep -v -u root and only matching the most recently started process (-n Select only the newest (most recently started) of the matching processes): $ pgrep -n # The most recent process started $ pgrep -n -u alice emacs # The most recent `emacs` process started by user `alice`


See also

* List of Unix commands * pidof — find the process ID of running programs * pkill — signal processes based on name and other attributes * ps — display the currently running processes * grep — search for lines of text that match one or many regular expressions


References

* * {{Unix commands Unix process- and task-management-related software