in reply to Last logon and time for a system console

This is a quick and dirty solution, only tested with gnu last from RHEL4 so may need a bit of tweaking to suit the output of your version of last.

last comes in reverse time order already, so the first value assigned to any host will be the latest log in from that host.

#!/usr/bin/perl use strict; use warnings; my @last= `last`; my (%time, @details, $host); map{ @details=split(/ +/); $host=$details[2]; $time{$host}=join (' ', @details[3,4,5,6]) unless $time{$host} ; }@last[0..$#last - 2]; map{ print "$_, last login at $time{$_}\n"; } keys %time;