hey guys i need some help here i am trying to do a bash shell script to get a parent PID and then search for all childs and kill them all without killing the parent, my problem is in the loop it seems that i dont know how to make a if statment inside a while statment it does not give me what i want.
#!/bin/bash
raqam=$(lui | grep EQUATION | nawk '{print $2}') # this will give me the parent PID
ps -ef | grep "$raqam" | nawk '{print $2}' > dump #dumping all PIDs of parent and child to dump
cat dump | while read line
do
if $line = $raqam
then
#i want here to skip this process ID
fi
kill -9 $line
done
in the
cat dump | while read line
is my problem i want the script to read every line and execute kill -9 for whats written in the file unless the line is = to $raqam .
can anyone here help plz