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

How to combine these two commands in bash:

lsof -i :port kill pid 

The first returns the PID I want to kill in order to free the port. The second one kills the returned PID.

I do this because I don’t know how to kill the dock web server in the Netbeans IDE on OSX. Is there any way?

+5
source share
2 answers

You can use $ ():

 kill $(lsof -t -i:port) 
+5
source

you can use

 kill -9 `lsof -t -i:port` 
0
source

Source: https://habr.com/ru/post/1233604/


All Articles