Skip to content

Instantly share code, notes, and snippets.

@darthchudi
Created February 27, 2021 06:13
Show Gist options
  • Save darthchudi/4ce3b9c9ae0a7455067fdb96a076ac8a to your computer and use it in GitHub Desktop.
Save darthchudi/4ce3b9c9ae0a7455067fdb96a076ac8a to your computer and use it in GitHub Desktop.
terminate a process running on a port
#!/bin/bash
terminatewithport(){
pid=$(lsof -i :$1 | awk 'FNR == 2 {print $2}')
echo "PID: $pid"
kill $pid
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment