Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 Linux 中使用“pgrep”命令获取两个或多个进程的 PID。
我们知道 pgrep 语法是
pgrep [options] <pattern>
这是一个假设的命令,它应该返回两个进程的 PID,其名称分别为process1和process2。
pgrep process1 OR process2
实现上述目标需要使用什么模式?
尝试:
pgrep 'process1|process2'
例子:
-->pgrep 'atd|cron' 1078 1093 -->ps -eaf |grep -E 'atd|cron' daemon 1078 1 0 Aug08 ? 00:00:00 /usr/sbin/atd -f root 1093 1 0 Aug08 ? 00:00:19 /usr/sbin/cron -f xxxx 14364 9597 0 11:56 pts/2 00:00:00 grep -E atd|cron