Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: parsing output of UNIX `who` command

by spadacciniweb (Deacon)
on Oct 02, 2006 at 08:39 UTC ( #575850=note: print w/replies, xml ) Need Help??


in reply to parsing output of UNIX `who` command

Try:
#!/usr/bin/perl use warnings; use strict; my $who = `who -q`; if ($who =~ /(.+)\n# users/) { $who = $1; } my @who = split / /,$who; my %who; foreach $_ (@who) { $who{$_}++; } foreach $_ (keys(%who)) { print $_, ' is logged ', $who{$_}, " times\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://575850]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2017-09-23 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (270 votes). Check out past polls.

    Notices?