What Makes `pgrep` Utility Unique Despite `ps | grep` Availability?


New Member
Apr 11, 2024
Reaction score
Could someone please explain the purpose of the pgrep utility when it seems like its functionality can be replaced with ps | grep? P.S. My teacher assigned me this question and asked me to explain why a new utility needed to be created if the same functionality exists in ps | grep. I suspect that 'pgrep' provides us with something that ps | grep does not, but what is it?

That's a tricky question, I don't agree with your teacher.

If you run pgrep --help and ps --help all you'll notice ps has far more options than pgrep so I'm not sure pgrep is more advanced.

I think pgrep is only more favorable than ps on command line when you yourself type something as compared to when you write scripts.
And the only reason for this is less typing, unlike in scripting where typing more is better for explicitness to make code more understandable to avoid "default bugs" that is those bugs which we don't notice due to default behaviors of options if not explicitly specified by administrator.
Reminder: We generally don't do homework questions. Though, we will give hints.

If it was me, I'd plug that question into AI - not to let AI write the answer but for AI to give you some hints.

Well, no... I'd first check the man pages side by side with two open terminals.