On Mon, 2 Jul 2001, eric pareja wrote:

> GECOS=`cat /etc/passwd | grep ^$USERNAME | cut -f5 -d: | cut -f1 -d,`

Funny, I'd use

GECOS=`grep ^$USERNAME: /etc/passwd | cut -f5 -d: | cut -f1 -d,`

but then again, I'm just lazy. =)

There's also

GECOS=`awk -F: "/^$USERNAME:/ { print \$5 } /etc/passwd"`

which is a little bit shorter. =)

You could also use perl or sed:

GECOS=`grep -e ^$USERNAME /etc/passwd | perl -pe 's/^(.*?:){4}(.*?):.*/$2/'

.. much longer but more fun.

Sacha 8)

_
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]

Reply via email to