Parse finger results for user name

chris (2003-07-01 00:00:46)
2827 views
0 replies
Another one of those random requests.. this time a friend, who wanted to be able to parse the output of a 'finger' command, echoing just the full name of the fingered user. I tested it on my onn userid - I think a name like 'Chris Lacy-Hulbert' is a good enough test for such meddling.

Anyway, here's the PERL:

#!/usr/bin/perl
use strict;
use File::Copy;
 
my $result=`finger chris`;
my @results=split("n",$result);
 
# iterate and copy each one
foreach (@results){
        chomp;
        $_ =~ /^Login/ || next;
        $_ =~ /Name:s(.*w$){1,}/ || next;
        printf("$1");
}
comment