How to kill all processes matching a name?

后端 未结 11 1533
不思量自难忘°
不思量自难忘° 2020-11-29 14:53

Say I want to kill every process containing the word amarok. I can print out the commands I want to execute. But how do I actually make the shell execute them. ie.



        
11条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 15:18

    You can also evaluate your output as a sub-process, by surrounding everything with back ticks or with putting it inside $():

    `ps aux | grep -ie amarok | awk '{print "kill -9 " $2}'`
    
     $(ps aux | grep -ie amarok | awk '{print "kill -9 " $2}')     
    

提交回复
热议问题