PGREP(1)                         proctools 0.4                        PGREP(1)

     pgrep - find processes

     pgrep [-filLnvVx] [-d delim] [-g pgrplist] [-G gidlist] [-P ppidlist] [-t
           termlist] [-u euidlist] [-U uidlist] [pattern]

     The pgrep utility displays process IDs for those processes that match the
     requirements specified on the command line.  The process IDs are present-
     ed as decimal numbers separated by an optionally supplied delimiter,
     which defaults to a newline.  The output can optionally include the exe-
     cutable name printed after the process ID, separated by a space.

     Processes are matched if the pattern, if given, matches the process's
     name, and the process matches any of the arguments given to all of the
     rest of the flags supplied on the command line.  The arguments supplied
     to pgrep can be given as a comma and/or whitespace delimited list.

     The options are as follows:

     -d delim
             Use the specified delimiter to separate the process IDs instead
             of a newline.

     -f      Match the pattern anywhere in the full argument string of the
             process instead of just the executable name.

     -g pgrplist
             Match only processes that exist within the process groups speci-

     -G gidlist
             Match only processes whose real group ID is listed.  Group IDs
             can be specified as group names and numeric IDs.  Non-existent
             numeric IDs do not cause errors.

     -i      Use case-insensitive pattern matching.

     -l      Print the executable name of the process along with the process

     -L      Print the full argument string of the process along with the pro-
             cess ID.

     -n      Print only the latest process that matches the rest of the argu-
             ments.  That is, the process that has the most recent start time.

     -P ppidlist
             Match only processes whose parent process ID is specified.

     -t termlist
             Match only processes whose controlling terminal is specified.
             Terminals can be specified as children of the /dev directory or,
             if starting with a leading slash (`/'), any currently mounted
             filename.  Filenames specified must be character devices.

     -u euidlist
             Match only processes whose effective user ID is given.  User IDs
             can be specified as usernames and as numeric user IDs.

     -U uidlist
             Match only processes whose real user ID is given.  User IDs can

             be specified as usernames and as numeric user IDs.

     -v      Invert the matching algorithm. Will print information about pro-
             cesses that do not match the given arguments.  As an exception,
             combining the -n option with the -v option will not invert the
             pattern match (only flags will be inverted).

     -V      Prints the pgrep version, then quits.

     -x      Treat the pattern as a literal string for exact (full-string)
             matching. Without this option, the default is to match as an ex-
             tended regular expression.  N.b. the Solaris pgrep performs regu-
             lar expression matching in the presence of the -x option. This
             behaviour is considered redundant in this pgrep implementation.
             The same effect may be achieved by avoiding the -x option and in-
             stead using a pattern of the form ^(pattern)$.

     pgrep sendmail

     Prints the process IDs of all sendmail processes.

     pgrep -G daemon -v

     Prints the process IDs of all processes whose group ID is not daemon.

     pgrep -d, -u root sh

     Prints the process IDs of all shells whose effective user ID is root,
     separated by commas.

     The pgrep utility exits with one of the following values:

     0 (EX_OK)
             One or more processes were matched.

     1       No processes were matched.

     64 (EX_USAGE)
             Invalid command-line options were specified.

             An unexpected error occurred.

     70 (EX_SOFTWARE)
             A feature was not supported in the current environment.

     71 (EX_OSERR)
             A transient error occurred.

     The current pgrep process will not consider itself to be a potential
     match. However, it is possible for a user to construct a shell pipeline
     that contains processes that will be matched by the pattern supplied to
     this tool. Some users might not anticipate this.

     The output of this tool should never be treated as accurate programmatic
     input (process arguments will have been escaped for safe printing on the

     The original Solaris pgrep could also match against session ID, but
     OpenBSD's session ID can fail to exist if the session leader exits.

     Also, the original Solaris version had only the deprecated -signal option
     to specify what signal to send.  This version can also use the -s signal
     option, which subsumes the session ID match listed above.

     Output with the -L option may vary between operating systems.

     For the sysctl mode of operation (e.g. Darwin) the -L option will list
     process belonging to other users but will be unable to display details of
     their arguments. A question mark and executable name (but not the argu-
     ment string) will be displayed.  (The Darwin ps can show arguments be-
     cause it is setuid root.)

     pkill(1), ps(1), regex(3)

     The original pgrep command appeared in Sun Solaris 7.

     Feedback may be sent to <wfaulk/> and <j-de-
     venish/>.  The project homepage is at <http://proc->.

                               06 December 2003                              3