Last active
August 16, 2018 21:42
-
-
Save SalemCode8/62ee3194708e4a4349017c0dd3592227 to your computer and use it in GitHub Desktop.
Kill Process Running On 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/sh | |
| # Author: Salem Code <salemode8@gmail.com> | |
| if [ -z "$1" ] | |
| then | |
| echo "\e[41mPort Number is Required\e[0m" | |
| exit | |
| fi | |
| PORT="$(lsof -i :$1 | awk '{print $2 }')" | |
| if [ -z "$PORT" ] | |
| then | |
| echo "\e[42mPort is Not In Use\e[0m" | |
| exit | |
| fi | |
| kill $(echo $PORT | grep -oP "\d+") | |
| echo "\e[42;1mProcess Killed Successfully\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment