pgrep 僅當前用戶

pgrep 僅當前用戶

我想知道有什麼論點使它pgrep只對當前用戶起作用。-u讓我提供名稱,我不知道目前使用者的名稱,我只知道我只需要當前使用者。

謝謝

答案1

您可以使用 UID或者一個名稱,如您所見man pgrep

   -u euid,...
          Only match processes whose effective user ID is listed.  Either the
          numerical or symbolical value may be used.

   -U uid,...
          Only match processes whose real user ID is listed.  Either the 
          numerical or symbolical value may be used.

如果您也不知道,只需使用命令替換:

pgrep -u "$(whoami)"

相關內容