相关疑难解决方法(0)

使用bash和regex在一行中查找并终止进程

我经常需要在编程期间杀死进程.

我现在这样做的方式是:

[~]$ ps aux | grep 'python csp_build.py'
user    5124  1.0  0.3 214588 13852 pts/4    Sl+  11:19   0:00 python csp_build.py
user    5373  0.0  0.0   8096   960 pts/6    S+   11:20   0:00 grep python csp_build.py
[~]$ kill 5124
Run Code Online (Sandbox Code Playgroud)

如何自动提取进程ID并在同一行中终止它?

像这样:

[~]$ ps aux | grep 'python csp_build.py' | kill <regex that returns the pid>
Run Code Online (Sandbox Code Playgroud)

regex bash terminal awk

595
推荐指数
13
解决办法
46万
查看次数

标签 统计

awk ×1

bash ×1

regex ×1

terminal ×1