Hacker News new | ask | show | jobs
by addingnumbers 1145 days ago
grep isn't necessary at all here:

  lsof -s TCP:LISTEN -i :$port
1 comments

You could also add the -t option for direct piping to kill.