Pgrep only current user

ps

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

Best Answer

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)"
Related Question