If you only need to support Linux (which I guess is the case given that your question is tagged linux), you can make use of the
Here is an example of what a script to do that could look like.
if [ "$#" != 1 ] || [ "$1" = "" ]
echo "Usage: $0 <full-exe-path>" 1>&2
shopt -s extglob
for PID in [1-9]*([0-9])
if [ "$(readlink "$PID"/exe)" = "$1" ]
One caveat to notice is that if the process ID is a kernel thread or is not owned by you
readlink will fail and
"$(readlink "$PID"/exe)" will evaluate to an empty string. To avoid attempting to kill all of those processes the script will refuse to do anything if
$1 is an empty string.
Also notice that this script makes use of
extglob which allows matching directories with
[1-9]*([0-9]) which means a character in the interval
1-9 followed by any number of characters in the interval