Last active
April 22, 2018 22:11
-
-
Save miguelmota/cd1194976ab6e6fdad54432a9701e72c to your computer and use it in GitHub Desktop.
bash script to kill process by name or port (like `fkill` NPM package, but not taking up your entire disk space with node_modules)
This file contains 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
# kill process by name or port | |
# example: | |
# fkill someapp :8080 node :1111 | |
fkill() { | |
for i in $@;do export q=$i;if [[ $i == :* ]];then lsof -i$i|sed -n '1!p'; | |
else ps aux|grep -i $i|grep -v grep;fi|awk '{print $2}'|\ | |
xargs -I@ sh -c 'kill -9 @&&printf "X %s->%s\n" $q @';done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment