Last active
October 6, 2015 16:38
-
-
Save soh-i/3022641 to your computer and use it in GitHub Desktop.
ちょっと監視してた
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my $name = {}; | |
my @cmd = `last`; | |
for (reverse @cmd) { | |
next if $_ =~ /wtmp|^\s+/; | |
my ($user, undef, $from, $w, $m, $d, $t) = split /\s+/; | |
my $login_date = "$w $m$d $t"; | |
$name->{$user}->{User} = $from; | |
$name->{$user}->{Count}++; | |
$name->{$user}->{Login} = $login_date; | |
} | |
foreach my $usr (sort | |
{ $name->{$b}->{Count} <=> $name->{$a}->{Count} | |
} keys %{ $name }) { | |
printf "%-10s", $usr; | |
printf "%-10s", $name->{$usr}->{Count}; | |
printf "%-10s\n", $name->{$usr}->{Login}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment