Unix/Linux命令行小技巧(1)- 显示运行进程的PID

Bash中定义如下函数(函数参数为程序名):

findpid() { ps axc|awk "{if (\$5==\"$1\") print \$1}"; }

执行效果:

[root@localhost ~]# findpid() { ps axc|awk "{if (\$5==\"$1\") print \$1}"; }
[root@localhost ~]# findpid tail
16049
25206
40701
48132

技巧出处:https://twitter.com/nixcraft/status/158835574508240896

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理