Hacker News new | ask | show | jobs
by lma21 1148 days ago
To avoid any unwanted matches with grep (e.g. ports 1999 and 19999), use:

    $ lsof -i:$port | grep LISTEN
    $ kill $pid
1 comments

grep isn't necessary at all here:

  lsof -s TCP:LISTEN -i :$port
You could also add the -t option for direct piping to kill.