Skip to content

Instantly share code, notes, and snippets.

@Aaronius
Created March 17, 2017 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aaronius/a155a6e874a9fd34d4a7a9244d18237b to your computer and use it in GitHub Desktop.
Save Aaronius/a155a6e874a9fd34d4a7a9244d18237b to your computer and use it in GitHub Desktop.
Kills a port. Put it in /usr/local/bin. Run it like so: `stopport 3000`
#!/bin/bash
lsof -i tcp:$1 | awk 'NR!=1 {print $2}' | xargs kill
@Aaronius
Copy link
Author

Better?

lsof -i TCP:$1 | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} LISTEN | awk '{print $2}' | xargs kill -9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment