kill a group of process within the same name
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/bin/bash
if [[ $# -ne 1 ]];then
echo "process name?"
exit 0
fi
all=`ps -A|grep $1`
for i in $all
do
p=`echo $i |grep -x -o -E "[0-9]+"`
if [[ -z $p ]]; then
continue
fi
sudo kill $p
done
ps -A|grep $1
|
Tags: kill
why don't you use
pgrep
?