I tried 'diff' -the trouble there is that the items in the two files don't always appear in the same order. It simply doesn't work. I'll take a peak at the links you suggested though. | [reply] [Watch: Dir/Any] |
#!/usr/bin/perl
use strict;
use warnings;
my $master = shift;
my $completed = shift;
open my $mh, '<', $master or die "Open fail on $master: $!";
my @master_lines = <$mh>;
chomp @master_lines;
open my $ch, '<', $completed or die "Open fail on $completed: $!";
my @completed_lines = <$ch>;
chomp @completed_lines;
my %count;
for my $element (@master_lines) {
$count{$element}|=1;
}
for my $element (@completed_lines) {
$count{$element}|=2;
}
print "$master only:\n";
for my $element (@master_lines) {
next if $count{$element} & 2;
print "$element\n";
}
print "$completed only:\n";
for my $element (@completed_lines) {
next if $count{$element} & 1;
print "$element\n";
}
| [reply] [Watch: Dir/Any] [d/l] [select] |
$ diff <( sort master ) <( sort completed ) | grep '^<' | cut -d ' ' -
+f2-
Depending on your needs you may want to use sort -u instead of a simple sort.
Or if you're under some Debian-derivative distro just install the moreutils package and use combine:
$ combine master not completed
1ao8A
1jkxA
1juvA
1mejA
1meoA
1n0uA
1pjqA
Hope that helps.
| [reply] [Watch: Dir/Any] [d/l] [select] |
I often use comm instead of diff, too.
| [reply] [Watch: Dir/Any] [d/l] [select] |