bash pid输出显示两个数字



我正在运行以下bash脚本对不起,这里是bash编程的新手!)我很难理解我写的脚本的输出,比如:

#!/bin/bash
PROCID=$(pgrep firefox)
echo "the process is $PROCID"

当运行上面的.sh脚本时,我得到:

the process is 2185
9341

我对这个9341数字深感不安——这是什么?我试着在谷歌上搜索,但找不到对此的解释。

如果这是一个101的问题,谢谢,也很抱歉。

DESCRIPTION
       pgrep looks through the currently running processes 
       and lists the process IDs which matches the selection criteria to stdout.  
       All the criteria have to match.

你可能有不止一个firefox进程在运行,你可以使用进行验证

ps aux | grep -e 2185 -e 9341

原因是您的机器上运行了多个firefox进程。使用ps aux|grep firefox验证,您应该获得相同的进程ID。

相关内容

最新更新