0
votes

How to compare two large files using perl? Using grep is very slow on large files. eg: less file1 |grep -f file2 > file3 eg: content in file1: 123;456;789 234;567;890 789;345;123 context in file2: 345 123 file3 output: 123;456;789 789;345;123 How to get the same output faster?

1
Your example is very odd. If you are comparing files, use diff or cmp. - Ned
As for your example, replace less with cat if you simply want to feed the contents of file1 to the standard input of grep. - Ned

1 Answers

0
votes

Because it looks like you are searching for lines in file1 which include one of a list of string literals given one per line in file2, try the following command line:

fgrep -f file2 file1 > file3