From owner-freebsd-questions Tue Sep 28 6:25:46 1999 Delivered-To: freebsd-questions@freebsd.org Received: from laurasia.com.au (lauras.lnk.telstra.net [139.130.93.142]) by hub.freebsd.org (Postfix) with ESMTP id 49B2315528 for ; Tue, 28 Sep 1999 06:25:36 -0700 (PDT) (envelope-from mike@laurasia.com.au) Received: (from mike@localhost) by laurasia.com.au (8.9.3/8.9.3) id VAA46614; Tue, 28 Sep 1999 21:25:29 +0800 (WST) (envelope-from mike) From: Michael Kennett Message-Id: <199909281325.VAA46614@laurasia.com.au> Subject: Re: Dumping Usernames and Real Names In-Reply-To: <005801bf09b3$711ec0a0$040aa8c0@jason> from Jason at "Sep 28, 1999 09:14:48 am" To: username@tir.com (Jason) Date: Tue, 28 Sep 1999 21:25:29 +0800 (WST) Cc: freebsd-questions@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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