* Compaiting two files
@ 2003-12-23 17:03 Robert Binkley
0 siblings, 0 replies; only message in thread
From: Robert Binkley @ 2003-12-23 17:03 UTC (permalink / raw)
This can be easily done with a simple Perl script...
- - - - - - - - - - snip - - - - - - - - - -
#!/bin/perl
open(FD,"<file1") or die "could not open file1: $!\n";
while ( <FD> ) {
chomp;
$in_file1{$_} = 1;
}
close(FD);
open(FD,"<file2") or die "could not open file2: $!\n";
while ( <FD> ) {
chomp;
next if ( $in_file1{$_} );
print "$_\n";
}
close(FD);
- - - - - - - - - - snip - - - - - - - - - -
Now, if file1 looks like this:
>cat file1
Item1
Item2
Item3
Item4
and file2 looks like this:
>cat file2
Item5
Item4
Item2b
Item1
Item6
then the output of the above Perl script will look like this:
>perl perlscript
Item5
Item2b
Item6
Is that what you're looking for?
Note that this could be easily modified to accept file names on the command
line. The output could also be sorted if so desired.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-12-23 17:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-23 17:03 Compaiting two files Robert Binkley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox