Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!sci.kun.nl!cs.kun.nl!hansm From: hansm@cs.kun.nl (Hans Mulder) Newsgroups: comp.unix.shell Subject: Re: Retrieving unique user numbers Message-ID: <3483@wn1.sci.kun.nl> Date: 26 Apr 91 14:23:58 GMT References: <1991Apr25.153217.9572@oakhill.sps.mot.com> Sender: root@sci.kun.nl Distribution: comp.unix.shell Organization: University of Nijmegen, The Netherlands Lines: 41 In <1991Apr25.153217.9572@oakhill.sps.mot.com> root@oakhill.sps.mot.com (Operator) writes: >Hello all -- >I was asked by a user how to retrieve/identify the unique >user number from within the shell environment (ksh). What >he is looking for would, preferably, function in much the >same fashion as the command [echo `/usr/bin/logname`], where >the result of this op could then be piped into a subsequent >operation. On this system (running SunOS 4.1.1) id | sed 's/[^=]*=//;s/(.*//' tells you your uid. You didn't say what OS you are running. The man page for id(1v) suggest that it is a SysVism, so it may not be available on your system. If you're worried about the efficiency of invoking sed, you'll have to write a C program that prints the output of the getuid() system call. BTW, is there any difference between echo `/usr/bin/logname` and logname ?? In general, the echo `...` constructs reduces whitespace, but your users don't have whitespace in their login names, have they? >Many thanks, You're welcome >Vance Hans Mulder hansm@cs.kun.nl