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
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)"
pgrep
does all users huh? – Noitidart Feb 12 '16 at 07:28${UID}
should do, otherwise"${USER}"
. – Asclepius Apr 23 '18 at 17:46