bsmoo
bsmoo

Reputation: 1049

Get a list of people who are logged in

I am trying to diplay the firstname and lastname of all the user that a logged in by parsing the output of finger. This is what I have tried:

finger | awk '{$1=$4=$5=$6=$7=$8=$9=$10=""; print}' | tail -n +2

Output:

Fname Sname 
Fname Sname 
Fname Sname 
Fname Sname 
Fname Sname

Is there any way I can get the same output with a tidier command?

Thanks.

All help and comments appreciated

Upvotes: 2

Views: 97

Answers (1)

Chris Seymour
Chris Seymour

Reputation: 85775

I think this is what you want:

finger | awk 'NR>1{print $2,$3}'

This will just print the first name and surname of the users skipping the header. Just print the columns you actually want, don't try and do the inverse.

Upvotes: 1

Related Questions