2 ms·
To avoid any unwanted matches with grep (e.g. ports 1999 and 19999), use: $ lsof -i:$port | grep LISTEN $ kill $pid
by lma21 3y ago
To avoid any unwanted matches with grep (e.g. ports 1999 and 19999), use:
$ lsof -i:$port | grep LISTEN
$ kill $pid
- addingnumbers 3y agogrep isn't necessary at all here: lsof -s TCP:LISTEN -i :$port
- hdjjhhvvhga 3y agoYou could also add the -t option for direct piping to kill.