fgrep -x -f file2 -v file1
-x match whole line
-f FILE takes patterns from FILE
-v inverts results (show non-matching)
OR
use strict;
use warnings;
my %file2;
open my $file2, '<', 'file2' or die "Couldn't open file2: $!";
while ( my $line = <$file2> ) {
++$file2{$line};
}
open my $file1, '<', 'file1' or die "Couldn't open file1: $!";
while ( my $line = <$file1> ) {
print $line unless $file2{$line};
}
-x match whole line
-f FILE takes patterns from FILE
-v inverts results (show non-matching)
OR
use strict;
use warnings;
my %file2;
open my $file2, '<', 'file2' or die "Couldn't open file2: $!";
while ( my $line = <$file2> ) {
++$file2{$line};
}
open my $file1, '<', 'file1' or die "Couldn't open file1: $!";
while ( my $line = <$file1> ) {
print $line unless $file2{$line};
}
No comments:
Post a Comment