0


I'm trying to extract the identical content from two text files.

For example:
first file:
1
2
3
4

second file:
4
5
6
7

I should return '4'.

I'm trying to use grep in bash file to read lines from first file and search on second. But this method is very slow. Please help to find another fastest way to complete this task with using RAM.

Thanks.

user2993877
  • 21
  • 1
  • 6
  • The first file size ~3Gb with 90 000k rows, the second is ~2Gb with 50 000k rows. – user2993877 Dec 08 '17 at 05:05
  • `grep -Fxf file1 file2` is about as fast as it's going to get. I am guessing you are using a `while read -r line` loop to make things slower, but without seeing your code, we can't help you more than that. – tripleee Dec 08 '17 at 05:35

0 Answers0