in reply to Compare 2 files and create a new one if it matches
Pure Perl solutions are no doubt best, but one could read the smaller file into an array, add appropriate markers, e.g. escaped pipe symbols at both ends of each element, eliminate duplicates, and write the resulting array to a new file, and use fgrep -f, capturing its output by using backticks (`).
Being a brute-force-and-ignorance sort of guy, my first pure Perl attempt would be to read both files into arrays, generate a really, really long regex from the search criteria (smaller) file, and use grep. Given my Perl-mojo, this would not work, and I'd have to loop through the individual records of the larger file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Compare 2 files and create a new one if it matches
by ikegami (Patriarch) on Sep 22, 2008 at 20:15 UTC | |
by swampyankee (Parson) on Sep 23, 2008 at 01:50 UTC | |
by ikegami (Patriarch) on Sep 23, 2008 at 02:05 UTC |