Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Syntactic Confectionery Delight
 
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"; }


Comment on Re: parsing output of UNIX `who` command
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://575850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2014-04-20 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls