The pgrep command looks at the active processes on your system and displays information matching the criteria you specified.
Let’s see some sample usage.
List all the processes owned by root as long as process names:
pgrep -l -u root
In the same way list all the processes owned by snort and apache users and use “, ” (comma+white space) as field delimiter:
pgrep -l -u snort,apache -d”, “
List the processes whose controlling terminal is pts/0:
pgrep -l -t pts/0
List the processes whose controlling terminal is NOT pts/0:
pgrep -l -t pts/0 -v
References: