Solução Perl, usando Text :: Table para uma boa formatação de saída:
#!/usr/bin/perl
use warnings;
use strict;
use Text::Table;
my %t;
my ($router, $ip, $column);
while (<>) {
if (/==>/) {
($router, $ip, $column) = /(.*) ==> ([0-9.]+) (\S+)/;
} else {
chomp;
push @{ $t{$router}{$ip}{$column} }, $_;
}
}
my @columns = qw( If_Name If_index If_status );
my $tt = 'Text::Table'->new('routerName', 'IPadd', @columns);
for my $router (keys %t) {
for my $ip (keys %{ $t{$router} }) {
for my $i (0 .. $#{ $t{$router}{$ip}{ $columns[0] } }) {
my @values = map $t{$router}{$ip}{$_}[$i], @columns;
$tt->add($router, $ip, @values);
}
}
}
print $tt;