Ninjastic
Home
Search
Users
Boards
Addresses
Ctrl + K
Toggle theme
Open menu
Post
Edited versions
Quotes to this post
Post
52546154
Topic
5183404
Board
Development & Technical Discussion
Re: python script compare lines in 2 text files and output matches
by
LoyceV
on
24/09/2019, 15:57:19 UTC
Does it have to be python? Bash command
comm
does exactly what you need
:
Code:
comm -12 <(sort file1) <(sort file2)
I don't know how fast a Python loop would be, but the above code takes about 0.05 seconds for 2 files with 50,000 lines each.