I have a large file containing one string on each line. I would like to be able to quickly determine if a string is in the file. Ideally, this would be done using a binary chop type algorithm.
Some Googling revealed the look
command with the -b
flag which promises to locate and output all strings beginning with a given prefix using a binary search algorithm. Unfortunately, it doesn't seem to work correctly and returns null results for strings that I know are in the file (they are properly returned by the equivalent grep
search).
Does anyone know of another utility or strategy to search this file efficiently?
look
command to function correctly, because look seems to ignore the locale and just uses C like sorting hardcoded, I also opened a bug because of this confusing behaviour: bugzilla.kernel.org/show_bug.cgi?id=198011look -b
failed for me with an errorFile too large
. I think it's trying to read the whole thing into memory.