Categories
Q & A Q & A Code

⨘ } extract a pattern from file – perl

#!/usr/bin/perl

use strict;
use warnings;

open my $FH, ‘<‘, $ARGV[1] or die “Could not open file: $ARGV[1] $!\n”;
open my $EXT_FH, ‘>’, $ARGV[2] or die “Could not open file: $ARGV[2] $!\n”;

while (my $line = <$FH>){
if ($line =~ /cabist|tap|fscan|fbscan|dangle) print $EXT_FH $line;
}

close $FH;
close $EXT_FH;

 796 total views,  5 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.