从命令行杀死所有进程

use*_*707 4 unix macos command-line

我想从命令行中杀死所有的firefox进程.

例如:

MacPro:huangr$ ps -x | grep 'firefox'
 4147 ttys000    0:00.00 (firefox-bin)
 4177 ttys000    0:00.00 (firefox-bin)
 4234 ttys000    0:00.00 (firefox-bin)
 4273 ttys000    0:00.00 (firefox-bin)
 4282 ttys000    0:00.00 (firefox-bin)
 4285 ttys000    0:00.00 (firefox-bin)
 4298 ttys000    0:00.00 (firefox-bin)
 4301 ttys000    0:00.00 (firefox-bin)
 4304 ttys000    0:00.00 (firefox-bin)
 4311 ttys000    0:00.00 (firefox-bin)
 4317 ttys000    0:00.00 (firefox-bin)
 4320 ttys000    0:00.00 (firefox-bin)
 4338 ttys000    0:00.00 (firefox-bin)
 4342 ttys000    0:00.00 (firefox-bin)
 4377 ttys000    0:03.85 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
 4394 ttys000    0:05.54 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
 4471 ttys000    0:06.08 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
 4581 ttys002    0:04.92 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
 4607 ttys002    0:04.33 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
 4626 ttys002    0:05.04 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -foreground
Run Code Online (Sandbox Code Playgroud)

我想一次性杀死所有这些,任何简单的方法吗?谢谢.

小智 9

kill -9 $(ps -x | grep 'firefox' | awk '{print $1}')
Run Code Online (Sandbox Code Playgroud)

应该这样做