kill multiple processes by name

Want to kill multiple processes by name. for the example below, I want to kill all 'proxy-stagerd_copy' processes.

I tried this but didn't work:

>> ps -ef|grep proxy_copy

root 991 986 0 14:45:34 ? 0:04 proxy-stagerd
root 1003 991 0 14:45:49 ? 0:01 proxy-stagerd_copy 1
root 1006 991 0 14:45:49 ? 0:00 proxy-stagerd_copy 4
root 1005 991 0 14:45:49 ? 0:00 proxy-stagerd_copy 3
root 1004 991 0 14:45:49 ? 0:01 proxy-stagerd_copy 2
root 1001 991 0 14:45:49 ? 0:00 proxy-stagerd_copy 0
root 1007 991 0 14:45:49 ? 0:00 proxy-stagerd_copy 5

>> killall -9 proxy-stagerd_copy

If one of you gurus could help me out, that would be great.

Thanks.

ps -ef|awk '/proxy-stagerd_copy/{print $2}' |xargs kill -9 
1 Like

Thanks will have to read up more on awk.