Does anyone know of a way to do something similar to this with awk and kill? I want to create the variable in awk and pass that variable to kill.
ps -ef | grep -i chromium | awk '{$2=x}' | kill -9 $x 2>/dev/null
Does anyone know of a way to do something similar to this with awk and kill? I want to create the variable in awk and pass that variable to kill.
ps -ef | grep -i chromium | awk '{$2=x}' | kill -9 $x 2>/dev/null
You don't need to pass variable.
ps -ef | grep -i chromium | awk '{print $2}' | xargs kill -9
BTW, Is it really necessary to use SIGKILL (-9) ?
Also, Your command would also list the grep invocation I guess.
Is killing the chromium is all you want to do? If so try this
pgrep chromium | xargs kill -9
--ahamed
For some programs yes ;).
xargs is the easy way :P. I wanna do it the complicated way :D.
Without xargs please :). I wanna do it the complicated way :D.
The most complicated way is try and discover yourself. Isn't it? :rolleyes:
If the OP decides to use something simpler later, some OS provides pkill
pkill <process_name>
then this one?
kill -9 `pgrep chromium`
or
die chromium die!
:D:D:D
--ahamed
I can't get the bloody syntax right :(.
This is actually the reason why I am trying to do this. pkill won't work on some programs :(.
pgrep has the same problem as pkill :(.
I wish :).
Are you sure? This one works for me:
pkill -f chromium
How about you describe your actual problem and not just the way you want to solve it.