That may work in this case, assuming the genes are all the same length. But it would also match if a line from file1 appeared a a substring of a line in file2, so a more general non-perl solution to "I want the lines two files have in common" is to use comm. My guess is that using comm on two sorted files is probably less resource-intensive than asking grep to turn an entire file into search strings, too.
sort file1 >file1.sorted sort file2 >file2.sorted comm -12 file1.sorted file2.sorted >common.lines
Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.
In reply to Re^2: Common between two lists
by aaron_baugher
in thread Common between two lists
by perllearner007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |