Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am used to using this command line to kill any process match said COMMAND
for i in $(ps -ef | grep COMMAND | awk '{ print $2 }'); do kill -9 "$i" &>/dev/null;done
shellcheck does not like it much and suggests
root@singa /home # shellcheck run
In run line 4:
for i in $(ps -ef | grep COMMAND | awk '{ print $2 }'); do kill -9 "$i" &>/dev/null;done
^-- SC2009: Consider using pgrep instead of grepping ps output.
what are the flags needed to complete this here replacing the XXX
for i in $(pgrep XXX | grep COMMAND | awk '{ print $2 }'); do kill -9 "$i" &>/dev/null;done
I have already checked the man page for pgrep.
–
i have done below method
for i in pickup hald-runner; do pgrep $i | awk '{print "kill" " " $1}'| sh;done
Here pickup,hald-runner is the process names