Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

pgrep

From Wikipedia, the free encyclopedia
Command-line utility that searches and displays named processes
pgrep
Original author(s)Mike Shapiro
Operating systemUnix andUnix-like
TypeCommand

pgrep is acommand-line utility initially written for use with theSolaris 7 operating system byMike Shapiro. It has since been available inillumos and reimplemented for theLinux andBSDs (DragonFly BSD,FreeBSD,NetBSD, andOpenBSD). It searches for all the namedprocesses that can be specified as extendedregular expression patterns, and—by default—returns theirprocess ID. Alternatives includepidof (finds process ID given a program name) andps.

Example usage

[edit]

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

$pgrep'bash'

Which is roughly equivalent to:

$psax|awk'{sub(/.*\//, "", $5)} $5 ~ /bash/ {print $1}'

Additional functionality ofpgrep 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 groupalice (-G Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used):

$pgrep-l-Galice

showing all processes that do not belong to the userroot (-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-uroot

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-ualiceemacs# The most recent `emacs` process started by user `alice`

See also

[edit]
  • List of Unix commands
  • pidof — find theprocess 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

[edit]
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
Retrieved from "https://en.wikipedia.org/w/index.php?title=Pgrep&oldid=1042957978"
Category:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp