如何杀死 linux 中的底部和进程

how to kill bottom n procceses in linux

通过使用 pgrep python 我可以按 PID 过滤进程:

[@~]$ pgrep python
725886
726128
726379
726816
732699
757708
769148

如何在一行代码中杀死前n个进程?

过滤传杀

pgrep python | head -n $n | xargs kill