Hello,
I am running into a little issue. What I am trying to accomplish is to compare two files and find which lines don't match. The problem is that the lines may not be in the same order. And the files may be too big for an array (not sure).
Basically:
## Some command outputs FileListing.txt
## listing files and directories, one per line
## Some other command outputs BackedUpFiles.txt
## listing files and directories, one per line
## I need to compare the two files and have the output
## be files in FileListing.txt and not in BackedUpFiles.txt
## I tried using File::compare, but there didn't seem to
## be a way to output the differences.
## I tried using Text::diff, but the app compares each text
## file line per line. I need to compare line per whole text
## file.
## I just saw a grep post; that might be the ticket.
## However, 1 question, file size is around 33 MB / file.
## This translates to roughly 550,000 lines per file.
## is this going to be a problem for the array?
# open(F,"yourfile");
# @list=<F>;close F;
# $this="String I want";
# @f=grep /$this/,@list;
#
open (F, "BackedUpFiles.txt");
@compare = <F>; close F;
open (F, "FileListing.txt");
@against = <F>; close F;
foreach (@against) {
@missing = grep -v /$_/,@compare;
}
print "These files did not get backed up: \n";
print "@missing \n";
## This looks like it might work. But can I pass -v to grep?
## Is there another way to pass the -v option?
##
## Will this work? Is there a better way to do this?
## Thanks to all who answer.
## Cory M.
I am running into a little issue. What I am trying to accomplish is to compare two files and find which lines don't match. The problem is that the lines may not be in the same order. And the files may be too big for an array (not sure).
Basically:
## Some command outputs FileListing.txt
## listing files and directories, one per line
## Some other command outputs BackedUpFiles.txt
## listing files and directories, one per line
## I need to compare the two files and have the output
## be files in FileListing.txt and not in BackedUpFiles.txt
## I tried using File::compare, but there didn't seem to
## be a way to output the differences.
## I tried using Text::diff, but the app compares each text
## file line per line. I need to compare line per whole text
## file.
## I just saw a grep post; that might be the ticket.
## However, 1 question, file size is around 33 MB / file.
## This translates to roughly 550,000 lines per file.
## is this going to be a problem for the array?
# open(F,"yourfile");
# @list=<F>;close F;
# $this="String I want";
# @f=grep /$this/,@list;
#
open (F, "BackedUpFiles.txt");
@compare = <F>; close F;
open (F, "FileListing.txt");
@against = <F>; close F;
foreach (@against) {
@missing = grep -v /$_/,@compare;
}
print "These files did not get backed up: \n";
print "@missing \n";
## This looks like it might work. But can I pass -v to grep?
## Is there another way to pass the -v option?
##
## Will this work? Is there a better way to do this?
## Thanks to all who answer.
## Cory M.