username <-> UID

Rob den Boer rob.den.boer at derijke.nl
Fri Oct 10 08:30:00 GMT 1997


Luke,



 > From: Luke Kenneth Casson Leighton <lkcl at switchboard.net>
 > To: samba at samba.anu.edu.au
 > Subject: programming question, for samba.
 >Message-ID: <Pine.BSF.3.91.971009152807.9779I-100000 at cb1-gw.cb1.com>

 > help, help.  does anyone know of a generic way to convert string   
username
into a uid (user id)?



Put this in a script and make it executable:

awk 'BEGIN{FS=":"} { if ($1 == name) print $3}' name=$1 /etc/passwd

Works on almost every Unix flavour...

regards,
Rob den Boer


More information about the samba mailing list