linuxbashshellterminalcommand

How to combine "lsof -i :port" and "kill pid" in bash


How do i combine these two commands in the bash:

lsof -i :port
kill pid

The first one returns the PID i want to kill to release the port. The second one kills the returned PID.

I am doing this because I don´t know of any way to kill a jetty webserver within the Netbeans IDE on OSX. Is there a way?


Solution

  • You can use $():

    kill $(lsof -t -i:port)