I have a script that prints out data as shown below
#! /usr/bin/perl
use strict;
chdir "/logs/cals";
my @files = `ls -1rt |tail -10`;
foreach my $files (@files) {
open FILE, $files or die "Can not open $files $!\n";
while (<FILE>) {
my $users = /(^\S+)\s+.*user\s+(\S+)\s
+Sync.*?\s
+.*/;
print "$2\t$1\n" if $users;
}
close FILE;
}
hchandrasekhar 2008/05/10
hchandrasekhar 2008/01/21
hchandrasekhar 2008/03/23
hchandrasekhar 2008/03/09
hodgson2 2008/05/09
hodgson2 2008/05/11
hodgson2 2008/04/12
hodgson2 2008/05/04
hsebastian 2008/02/25
hsebastian 2008/03/15
hsebastian 2008/02/19
hsebastian 2008/05/04
__________________________
__________
__________
__________
__________
_
I'm trying to learn how to put this data in a % then sort it out to get only each users name and Most Recent date, each
name has many dates but I only want to get one entry for each user and get the most recent date. Adam showed me a way
to do this on another script but I'm just not getting it and trying to understand how to sort this out by most recent.
Thanks,
Start Free Trial