Comparing two lists

John Levine johnl at
Sat May 7 03:10:47 UTC 2011

>Some 10,000 to 20,000 lines each. I do need only the common lines. Order 
>is not essential, but would make life easier. I've tried a little with 
>uniq, as suggested by Polyptron, but I guess 3am is not quite the right 
>time to do these things. Anyway, thanks.

 sort -u file1 > sorted-file1
 sort -u file2 > sorted-file2
 comm -12 sorted-file1 sorted-file2 > result


More information about the freebsd-questions mailing list