Created
February 27, 2021 06:13
-
-
Save darthchudi/4ce3b9c9ae0a7455067fdb96a076ac8a to your computer and use it in GitHub Desktop.
terminate a process running on a port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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