Efficient grep using Python?

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Thu Dec 16 12:22:46 CET 2004


On Wed, 15 Dec 2004 16:10:08 +0000, rumours say that P at draigBrady.com
might have written:

>> Essentially, want to do efficient grep, i..e from A remove those lines which
>> are also present in file B.
>
>You could implement elegantly using the new sets feature
>For reference here is the unix way to do it:
>
>sort a b b | uniq -u

No, like I just wrote in another post, he wants

$ grep -vf B A

I think that

$ sort A B B | uniq -u

can be abbreviated to

$ sort -u A B B

which is the union rather than the intersection of the files, wastes
some time by considering B twice, and finally destroys original line
order (should it be important).
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...



More information about the Python-list mailing list