Created
January 1, 2023 10:24
-
-
Save l3acucm/1395a61749f47d2b794bfba8c3c830f8 to your computer and use it in GitHub Desktop.
kill port on macos
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 | |
| if [ -z "$1" ] | |
| then | |
| echo "Port not specified" | |
| else | |
| greparray=$(lsof -i tcp:$1 | grep -Eo "\s(\d{5})\s") | |
| for pid in $greparray | |
| do | |
| kill -9 $pid | |
| echo $pid | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment