Extracting the "Name" field from "finger" output

Extracting the "Name" field from "finger" output

Post by Arcadius A » Tue, 02 Jul 2002 07:39:07



Hello!
I'm trying to extract users' real name from the output of the command
"finger"
The pipe I'm actually using is:



finger: /dev//:0: No such file or directory
Arcadius A.

Please, any idea about the error message?
( The error doesn't appear on my other FreeBSD box)

Is there any better way to get the Name field extracted?

Thanks.

ARcadius.

 
 
 

Extracting the "Name" field from "finger" output

Post by Erik Nygre » Tue, 02 Jul 2002 18:05:30



> Hello!
> I'm trying to extract users' real name from the output of the command
> "finger"
> The pipe I'm actually using is:



> finger: /dev//:0: No such file or directory
> Arcadius A.

> Please, any idea about the error message?
> ( The error doesn't appear on my other FreeBSD box)

> Is there any better way to get the Name field extracted?

I would do it like this:
finger -l arcad | head -1 | sed 's/.*Name: \(.*\)$/\1/'
but finger can be dangerous (try creating a huge .plan for instance)
so if the user is local, why not use
grep '^arcad' /etc/passwd | cut -d':' -f5
instead?

--
Erik Nygren
e r i k { a t } s w i p { d o t } n e t
Linux - If you hate Microsoft, FreeBSD - If you love Unix

 
 
 

Extracting the "Name" field from "finger" output

Post by Arcadius A » Wed, 03 Jul 2002 05:44:37


Quote:> > Please, any idea about the error message?
> > ( The error doesn't appear on my other FreeBSD box)

> > Is there any better way to get the Name field extracted?

> I would do it like this:
> finger -l arcad | head -1 | sed 's/.*Name: \(.*\)$/\1/'
> but finger can be dangerous (try creating a huge .plan for instance)
> so if the user is local, why not use
> grep '^arcad' /etc/passwd | cut -d':' -f5
> instead?

Hello!
Thanks for the tip!

However, as I'm not able to get this to work:

username="arcad";
grep '^$username' /etc/passwd | cut -d':' -f5

I think my problem is to get the grep understand that $username is a
variable...

Thanks...

Arcadius.

 
 
 

Extracting the "Name" field from "finger" output

Post by Charlie Sors » Sun, 04 Aug 2002 02:42:08



=
= > > Please, any idea about the error message?
= > > ( The error doesn't appear on my other FreeBSD box)
= > >
= > > Is there any better way to get the Name field extracted?
= >
= > I would do it like this:
= > finger -l arcad | head -1 | sed 's/.*Name: \(.*\)$/\1/'
= > but finger can be dangerous (try creating a huge .plan for instance)
= > so if the user is local, why not use
= > grep '^arcad' /etc/passwd | cut -d':' -f5
= > instead?
=
= Hello!
= Thanks for the tip!
=
= However, as I'm not able to get this to work:
=
= username="arcad";
= grep '^$username' /etc/passwd | cut -d':' -f5

$ username="doe"
$ grep '^$username' /etc/passwd | cut -d':' -f5
$

but

$ grep "^$username" /etc/passwd | cut -d':' -f5
John Doe
$

= I think my problem is to get the grep understand that $username is a
= variable...

Yep!

= Thanks...
=
= Arcadius.

--
Best regards,

Charlie "Older than dirt" Sorsby     Edgewood,  NM     "I'm the NRA!"

 
 
 

Extracting the "Name" field from "finger" output

Post by Charlie Sors » Sun, 04 Aug 2002 02:37:08





= > Hello!
= > I'm trying to extract users' real name from the output of the command
= > "finger"
= > The pipe I'm actually using is:
= >


= > finger: /dev//:0: No such file or directory
= > Arcadius A.

= >
= > Please, any idea about the error message?
= > ( The error doesn't appear on my other FreeBSD box)
= >
= > Is there any better way to get the Name field extracted?
=
= I would do it like this:
= finger -l arcad | head -1 | sed 's/.*Name: \(.*\)$/\1/'

Or how about:

PC% finger -l doe | head -1 | cut -f4 | cut -c 7-
John Doe
PC%

= but finger can be dangerous (try creating a huge .plan for instance)
= so if the user is local, why not use
= grep '^arcad' /etc/passwd | cut -d':' -f5
= instead?
=
= --
= Erik Nygren
= e r i k { a t } s w i p { d o t } n e t
= Linux - If you hate Microsoft, FreeBSD - If you love Unix

--
Best regards,

Charlie "Older than dirt" Sorsby     Edgewood,  NM     "I'm the NRA!"