Linux – Get the pid of the process in zsh

Get the pid of the process in zsh… here is a solution to the problem.

Get the pid of the process in zsh

I’m coding on a Red Hat machine and I want to get the process ID of the process in interactive mode and script.

‘pidof’ works in bash, but not in zsh.

What is the equivalent of pidof in zsh?

Thank you in advance.


You might want to determine the location of the pidof in bash and then try to run zsh using an absolute path.

If the above method works, you’re just running into a $PATH issue (because I’ve never seen pidof as a bash built-in function. )

If that doesn’t work, try the following:

It may not be as simple as you would like, but it worked for me :

pgrep -U $USER some_program

where “some_program” is the name you usually provide pidof.

Related Problems and Solutions