user590849 user590849 - 1 year ago 101
Linux Question

getting the pid of a process in zsh

I am coding on a Red Hat Machine and I want to get the process id of a process in the interactive mode as well as the in a script.

In bash 'pidof' works but not in zsh.

What would be the equivalent of pidof in zsh ?

Thank you in advance.

Answer Source

You may wish to which pidof in bash, to determine the location of pidof and then try running zsh with the absolute path.

If the above works, you just have a $PATH issue (as I have never seen pidof as a bash builtin.)

If that doesn't work try the following:

This is probably not a simple as you want, but it works for me:

pgrep -U $USER some_program

Where 'some_program' is the name you would normally supply pidof.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download