On Mon, 2 Jul 2001 at 15:44, Orlando Andico wrote:
> GECOS=`cat /etc/passwd | grep $USERNAME | cut -f5 -d:`
> where USERNAME would hold the username you want?
I stopped crying, checked the manpage of cut out, gave /etc/passwd another
look and refined Orly's really neat shell programming to accomodate my
needs:
GECOS=`cat /etc/passwd | grep $USERNAME | cut -f5 -d: | cut -f1 -d,`
For those who wish to hear me rave about this:
cat /etc/passwd reads /etc/passwd line by line to the console. The output
is piped to grep, which searches for occurences of $USERNAME and returns
the entire line that contains this. The output is piped to the first cut,
which, using a colon as a delimiter, returns the fifth field, which
contains the user's full name and other details like office and telephone
information. On Debian at least, keeping these blank still gets commas put
in there. The last cut cleans this out, by using a comma as a delimiter it
returns the first field which is always the full name. If the full name is
blank (or the entire fifth field is blank), then the result is nothing,
which is correct. :-)
Thanks Orly!
--> Jijo
--
Federico Sevilla III :: [EMAIL PROTECTED]
Network Administrator :: The Leather Collection, Inc.
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]
To subscribe to the Linux Newbies' List: send "subscribe" in the body to
[EMAIL PROTECTED]