6 Jun
2005
6 Jun
'05
13:24
Markus Natter writes:
this is an odd problem, yet simple..
I could not find a command line tool that would return me the user name belonging to a UID (number) independent from the underlieing auth mechanism.
It should be kind of a reverse "id" command.. the way an "ls" uses it.
It seems so trivial to me, but I didn't find an answer googling for it.
Here is one way to do it. Save the following shell script as /usr/local/bin/rid and chmod r+x the file. Usage: rid # --------X snip X-------- #!/bin/sh awk -F: '{ if ($3 == id) print $1 }' id=$1 /etc/passwd --------X snip X-------- -Ti