Created
August 5, 2015 09:20
-
-
Save felixexter/18e4df3c62352a3f72ad to your computer and use it in GitHub Desktop.
killbydir
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 | |
# add to /usr/local/bin/killbydir | |
# chmod +x /usr/local/bin/killbydir | |
path=`pwd` | |
for process in `pgrep $1`; do | |
foo=(`pwdx $process`) | |
if [ ${foo[1]} = $path ]; then | |
pid=${foo[0]::-1} | |
`kill -9 $pid` | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment