#!/usr/bin/env perl # # lastaggr - summarize last(1) output # # expects output from last -wxaiF # # $Id$ use strict; use warnings; my ( %l, %c, %md, %m, %y ); while (<>) { /\S/ or next; /^\S+ begins / and next; s/\(to lvl (\d)\)/to_lvl_$1/; s/system boot/system_boot/; my ( $u, $t, $wd, $m, $md, $hms, $y ) = split; $c{$u}++ and next; # this is the first entry for $u ( $l{$u}, $md{$u}, $m{$u}, $y{$u} ) = ( $., $md, $m, $y ); } foreach my $u ( sort { $l{$a} <=> $l{$b} } keys %l ) { print "$u,$c{$u},$md{$u},$m{$u},$y{$u}\n"; }