diff options
author | joeyh <joeyh> | 2006-03-06 03:33:23 +0000 |
---|---|---|
committer | joeyh <joeyh> | 2006-03-06 03:33:23 +0000 |
commit | 6a7f34809e87a940cd30c7e9de160db4ee9e65ca (patch) | |
tree | 373ce8f5df8986dba781ec07635d797598449407 /not | |
parent | 31bab120cc259d70b3706dbd7210159b4667171d (diff) | |
download | moreutils-0.4.tar.gz |
releasing version 0.40.4
Diffstat (limited to 'not')
-rwxr-xr-x | not | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -0,0 +1,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; |