0

How to search for a process by name without using grep?

In order to search for a process you can use ps with grep.

For example to search for firefox

ps aux | grep firefox
How to get the same answer without using grep?

grep Add a comment
wyatt
asked Mar 05 2019

Answer

0

The pgrep command, and pkill, exists precisely for this purpose:

pgrep firefox will list all processes whose commands match firefox
pgrep -f firefox will list all processes whose entire command lines match firefox
pgrep -x firefox will list all processes whose commands exactly match firefox

... and so on.

And naturally, pgrep will exclude itself from the match, so none of the grep rituals associated with ps | grep are needed

Add a comment
linuxhelp
asked Mar 05 2019
edited Mar 05 2019
Post your Answer