#list all process of t program
ps au |grep ./t |awk '{ print $2 }'


#Kill all process of t program
kill -9 `ps au |grep ./t |awk '{ print $2 }'`


replace ./t string for your grep condition

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/jtN1qp4RZks/12495