Grepping a list of words

John Levine johnl at iecc.com
Fri Aug 13 19:18:27 UTC 2010


>> Since I will have a need to run this check frequently, any suggestions for
>> a better approach are welcome.
>
>sort -u and comm(1)?

sort is O(N log N) while grep is O(N)

Which is faster depends on the constant factors in each, but as the
data sets get bigger, the log N term will dominate.  That is, for
small sets of data, I don't know which will be faster, but either will
be fast enough so who cares.  For large sets of data, the sort will be
slow.

R's,
John


More information about the freebsd-questions mailing list