cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:command:pgrep.html



Linux Commands#System

How to use pgrep Command in Linux

Help/Manual

# pgrep -h

Usage:
 pgrep [options] <pattern>

Options:
 -l, --list-name           list PID and process name
 -f, --full                use full process name to match
# man pgrep
       -f, --full
              The pattern is normally only matched against the process name.  When -f is set, the full command line is used.
       -l, --list-name
              List the process name as well as the process ID.  (pgrep only.)


Example

pgrep -f 'bash' | xargs kill
$ pgrep -lf 'bash'
3184 -bash
3208 /bin/bash
8562 /bin/bash
8618 /bin/bash
10216 /bin/bash
10251 /bin/bash
10314 /bin/bash
10650 -bash
10674 /bin/bash
11120 /bin/bash
$ pgrep -f 'bash'
3184
3208
8562
8618
10216
10251
10314
10650
10674
11120



os/linux/command/pgrep.html.txt ยท Last modified: 2021/02/26 by admin

Page Tools