In the man page of kill it is written as following


  kill [ -s signal | -p ] [ -a ] [ -- ] pid ...
  kill -l [ signal ]

  -p     Specify  that kill should only print the process id (pid) of the
          named processes, and not send any signals.

But as I tried many times in both RH and RHEL, command like kill -s SIGHUP |-p 123 never worked and an error is always reported

bash: -p: command not found

Did I make any mistakes?

  • 11
    Note that when you typed in the command, you removed the [ ] brackets, and replaced signal with SIGHUP and pid with 123? Why did you do that? Because you know that the symbols [, signal and pid are meta-syntactic, rather than literal. They indicate what the syntax is. Well, the | symbol is the same thing: another meta-syntactic indicator of syntax. [a | b] means: optional syntactic item, which can be either a or b (but not both since it must be one item).
    – Kaz
    Sep 20 '13 at 19:47
  • Thanks for your instruction. By the way, how do you pronounce [a | b]?
    – user43312
    Sep 21 '13 at 2:07
  • Hmm. "Optional A or B".
    – Kaz
    Sep 21 '13 at 3:42
kill [ -s signal | -p ]

This syntax in a manual page means:

You can use kill -s signal or you can use kill -p, but you can't use both -s and -p at the same time.

The pipe (|) stands for (exclusive) or in the documentation, it's not part of the command.

When you type

foo | bar

in your shell, it will attempt to start foo and bar, and pipe the output of foo to the bar program. (That's the shell doing that, not foo (or bar), the | is not passed to either process.) In your case, the second part is -p 123, so the shell tries to find an executable called -p and fails with that error message.

  • Thanks, @Mat. So I give a command like kill -p 123. It says bash: kill: p: invalid signal specification. And kill -p SIGINT 123 says the same thing. I don't think there is place to put the signal according to the syntax. Do you mind if you just give a demonstration of the use of the -p option?
    – user43312
    Sep 20 '13 at 7:58
  • 2
    @user43312: see slm's answer for that
    – Mat
    Sep 20 '13 at 9:29

I think you're getting tripped on the fact that there is a builtin command to Bash called kill, along with the command kill.

$ type -a kill
kill is a shell builtin
kill is /usr/bin/kill
kill is /bin/kill

The man page you're reading is referring to the kill command located under /bin. Use the full path to summon it:

$ /bin/kill -p sleep

Incidentally the /usr/bin/kill is just a link to /bin/kill.

$ ls -l /usr/bin/kill
lrwxrwxrwx 1 root root 14 Feb  9  2011 /usr/bin/kill -> ../../bin/kill

$ readlink -m /usr/bin/kill
  • This really works. And I appreciate for all the demos.
    – user43312
    Sep 21 '13 at 2:03
  • @user43312 - NP. Examples are always easier to follow than man pages 8-).
    – slm
    Sep 21 '13 at 2:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.