How to give arguments to kill via pipe [duplicate]
Solution 1:
kill $(ps -e | grep dmn | awk '{print $1}')
Solution 2:
In case there are multiple processes that you want to remove you can use this:
ps -efw | grep dmn | grep -v grep | awk '{print $2}' | xargs kill
Note: You need to remove grep process itself from the output, that's why grep -v grep
is used.
Solution 3:
You could use
pkill dmn
if your system has the pkill command.
Solution 4:
Just adding on others, but I like using awk's regex features capacity:
kill $(ps | awk '/dmn/{print $1}')