Skip to content

Instantly share code, notes, and snippets.

@BadgerBadgerBadgerBadger
Created September 6, 2016 04:43
Show Gist options
  • Save BadgerBadgerBadgerBadger/8769ae300d312e0797a776eacc796f5e to your computer and use it in GitHub Desktop.
Save BadgerBadgerBadgerBadger/8769ae300d312e0797a776eacc796f5e to your computer and use it in GitHub Desktop.
# Kills the process running at the port passed into the argument.
# `lsof -i :${1}` gets the processes running at the specified port.
# `awk NR==2` gets the second line which is the first record from lsof.
# `awk '{print $2}')` gets the second column, which is the pid of the process.
# This is evaluated and the result used as the arg for the `kill` command.
kill $(lsof -i :${1} | awk NR==2 | awk '{print $2}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment