in reply to parsing output of UNIX `who` command
who -q just gives the total number of users logged in on my system, so that's not very useful for counting how often each user is logged in.my %who; foreach my $user (`who`) { $user =~ /^(\S+)/ or next; $who{$1}++; } while (my($user, $count) = each(%who)) { print "$user is logged in $count time"; print $count == 1 ? ".\n" : "s.\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: parsing output of UNIX `who` command
by johngg (Canon) on Oct 02, 2006 at 10:13 UTC | |
by Anonymous Monk on Oct 02, 2006 at 12:11 UTC | |
by johngg (Canon) on Oct 02, 2006 at 13:21 UTC |