6

I was wondering what the arguments were for pgrep to make it act only on the current user. -u makes me provide names, I don't know the name of the current user, I just know that I need current user only.

Thanks

7

You can use a UID or a name, as you can see in 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.

If you don't know either, just use command substitution:

pgrep -u "$(whoami)"
| improve this answer | |
  • Ah that whomai thing is what I have to do. Thank you!! :) So by default, pgrep does all users huh? – Noitidart Feb 12 '16 at 7:28
  • ${UID} should do, otherwise "${USER}". – Acumenus Apr 23 '18 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.