Last active
March 12, 2020 00:32
-
-
Save harrisoncramer/08e43614735b37928eff289819387def to your computer and use it in GitHub Desktop.
Killport
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 [ $# -eq 0 ]; then | |
echo 'Must provide ports.' | |
exit 1 | |
fi | |
for var in "$@" | |
do | |
if [ "$var" -eq "$var" ] 2>/dev/null | |
then | |
echo Killing port: $var | |
lsof -i :${var} | awk 'NR>1 {print $2}' | xargs kill | |
else | |
echo "ERROR: $1 is not an integer." | |
exit 1 | |
fi | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment