In a Bash script:
#!/usr/bin/bash
#grep()
#{
#grep -q
#}
if [[ -z $1 ]];
then
echo "usage: pkill -signal process name "
fi
if [[ -z $2 ]];
then
echo "error: not enough parameters "
exit
fi
kill9="9"
kill15="15"
if [ $1 -eq $kill9 ]
then
set "9"
else
set "15"
fi
ARRAY=(
`ps -ef|grep $2 |grep -v grep|awk '{print \$2}'`
)
pkill()
{
PIDTODIE=${2}
for i in ${ARRAY[@]} ;do kill $1 $i;done
}
pkill $1 $2
Is it possible to assign in awk, $2 so that it becomes $b? Because $2 is a Bash parameter and gives me conflicts. Also the \$2 is not working.