w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
shell command to perl script with awk, grep

Untested:

#!/usr/bin/perl
use warnings;
use strict;

my %uniq;
open my $IN, '<', 'test.txt' or die $!;
while (my $line = <$IN>) {
    next unless $line =~ /warn/i;

    my $second_column = (split /:/, $line)[1];
    if ($second_column =~ /^[0-9A-Z]/i) {
        $second_column =~ s/ *$//;
        $uniq{$second_column} = 1;
    }
}
print "$_
" for keys %uniq;




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.