Date: Tue, 28 Sep 1999 21:25:29 +0800 (WST) From: Michael Kennett <mike@laurasia.com.au> To: username@tir.com (Jason) Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Dumping Usernames and Real Names Message-ID: <199909281325.VAA46614@laurasia.com.au> In-Reply-To: <005801bf09b3$711ec0a0$040aa8c0@jason> from Jason at "Sep 28, 1999 09:14:48 am"
next in thread | previous in thread | raw e-mail | index | archive | help
Jason wrote: > Is there a way I can dump all of the username and their associated "real > name" to a text file? I have looked at finger but their is no way to do all > users even if they are not logged into the system. Are their any commands > that will do this for me? Thanks in advance... > Hi Jason, A quick way is to use awk as follows: $ awk -F: '{print $1":"$5}' < /etc/passwd The manpage passwd (5) details the format of /etc/passwd. The small script above doesn't quite do what you want: it prints out the entire 'gecos' field of the passwd file. So it the user has used 'chfn' to change their details, the command above will also print out the office location, phone number etc... The pipe below strips out this information, leaving just the login name and the full name (separated with a colon ':') $ awk -F: '{print $1":"$5' < /etc/passwd | sed 's/,.*//' Regards, Mike Kennett (mike@laurasia.com.au) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199909281325.VAA46614>