blob: c67467c17a33fbb679bf900b959b0a9b866e299d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/perl
=head1 NAME
not - print lines that are present in one file but not another
=head1 SYNOPSIS
not file
not [file|-] [file|-] ...
=head1 DESCRIPTION
B<not> reads the specified files and prints out the lines that are present
in the first but not in subsequent files. Use "-" to make it read a file
from standard input. If only one file is specified, B<not> first reads
standard input, and compares it with the specified file.
=head1 AUTHOR
Copyright 2006 by Joey Hess <joey@kitenet.net>
Licensed under the GNU GPL.
=cut
use warnings;
use strict;
if (@ARGV == 0) {
die "usage: not [file|-] [file|-] ...\n";
}
if (@ARGV == 1) {
unshift @ARGV, "-";
}
my $first=shift;
my %seen;
foreach my $fn (@ARGV) {
open (IN, $fn) || die "and: read $fn: $!\n";
while (<IN>) {
chomp;
$seen{$_}++;
}
close IN;
}
open (IN, $first) || die "and: read $first: $!\n";
while (<IN>) {
chomp;
print "$_\n" if ! $seen{$_};
}
close IN;
|