Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for an equivalent of the unix look command, which searches a text file for lines beginning with a given prefix. In particular, it has an option for a binary search within a pre-sorted text file.

Does anything like this exist on Windows? I know about find, but it doesn't have the binary search option.

share|improve this question

migrated from stackoverflow.com Jun 30 '11 at 11:51

This question came from our site for professional and enthusiast programmers.

    
You don't say why you need the binary search option (or for that matter, why you would use look over grep. findstr /B does what you are asking, but it uses a linear search. –  Ryan Bemrose Jun 30 '11 at 8:07
add comment

2 Answers

up vote 1 down vote accepted

You can find look in util-linux which is straight from ftp.kernel.org/pub/linux/utils/util-linux. look.c is simple enough to be adapted to a mingw or msvc build environment without great hassles.

share|improve this answer
add comment

There's always Cygwin.

There's probably a native solution of course.

share|improve this answer
    
In this case cygwin is unavailable - but according to this page it looks like look isn't available on cygwin either. –  Timothy Jones Jun 30 '11 at 7:03
1  
lookshould be in util-linux which is straight from ftp.kernel.org/pub/linux/utils/util-linux. look.c is simple enough to be adapted to a mingw or msvc build environment without great hassles. –  Nordic Mainframe Jun 30 '11 at 7:06
    
Looks great Luther! If you repost that as an answer, I'll give you the check mark. Also, are there any automated tests for the utils? I couldn't see any in an obvious location in that archive. –  Timothy Jones Jun 30 '11 at 7:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.