How to update ‘pgrep’ in macOS to get around a known ‘pgrep -d’ issue

Posted on

QUESTION :

In the version of pgrep ( February 11, 2010 ) that is installed in macOS Catalina there is a bug when setting a delimiter. The delimiter should only be printed between each process ID but it’s also being printed as a line terminator.

This is documented here in the FreeBSD Bugzilla bug number 203744.

Is there a way to download an updated version of pgrep for macOS?

I also could not get the version of pgrep on my machine. Using pgrep -V results in an error. Using what gives me this:

what /usr/bin/pgrep
/usr/bin/pgrep
    PROGRAM:pkill  PROJECT:adv_cmds-174.0.1

ANSWER :

Sure can. Just install it via Homebrew!

Homebrew is a macOS package manager similar to yum in RedHat/CentOS Linux and apt-get in Debian/Ubuntu. It allows you to easily install packages that can supersede macOS built-in BSD (Darwin) commands and packages.

The first step to do this is to install Homebrew on your system like this; just open up a terminal and run the command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Homebrew is installed on your system then install the protocol package like this:

brew install proctools

And when that’s done, you can run your prgrep command and the version should be a more modern version that

Leave a Reply

Your email address will not be published. Required fields are marked *