#!/bin/sh perl -i~ -e ' # -i~ for in-place editing with tilde backup use strict; use warnings; my @a; my %excludehash; my $file = shift; open(excludelist, "< $file") or die; chomp( @a= ); close(excludelist); @excludehash{@a}=@a; { local($/) = ""; while (<>) { m/YOURKEY:\s+(.*)$/m; print unless exists $excludehash{ $1 } } }' "excludefile" "datafile" #### #!/bin/sh perl -i~ -e ' # -i~ for in-place editing with tilde backup use strict; use warnings; my %excludehash; my $file = shift; open(my $excludelist, "<", $file) or die; while(<$excludelist>) { chomp; next if /^$/; $excludehash{ $_ }=1; } close($excludelist); { local($/) = ""; while (<>) { next if ( m/^YOURKEY:\s+(.*)$/m && $excludehash{ $1 } ); print } }' "excludefile" "datafile" #### 1@1 Last, First #### random lines of data YOURKEY: 1@1 random lines of data random lines of data random lines of data YOURKEY: 2/ random lines of data YOURKEY: Last, First random lines of data random lines of data random lines of data YOURKEY: Apple's #### #!/bin/sh perl -i~ -e ' use strict; use warnings; my %excludehash; { local($/) = ""; { while(<>) { while (m/^OBSPOR: (.*)$/mg) { $excludehash{ $1 } = $1 } last if (eof) } } seek(ARGV, 0, 0); { while (<>) { m/^PORNUM:\s+(.*)$/m; print unless exists $excludehash{ $1 } } } }' "datafile"