in reply to Re^2: Searching text files
in thread Searching text files

grep and findstr are both O(n) linear searches. Maybe I'm missing something here, but I think that's what the OP is trying to avoid; a linear search that takes O(n) time to fail.


Dave

Replies are listed 'Best First'.
Re^4: Searching text files
by aquarium (Curate) on Sep 16, 2006 at 14:05 UTC
    forget O(n) etc. the original poster was slurping the whole files into memory, which was the cause of the slowness. grep will match the number in the 3 files (several megs total) in about a second....which surely meets the criteria for response time. the poster is a beginner, so would be best for them to have a one liner with a 1 second response time..rather than complicated code with at best 0.5 second response time.
    the hardest line to type correctly is: stty erase ^H
Re^4: Searching text files
by Not_a_Number (Prior) on Sep 14, 2006 at 19:27 UTC
    grep and findstr are both O(n) linear searches...

    Err, yes. But could you explain why you posted this as a reply to my node, which is explicitly tagged as a reply to aquarium rather than a solution to the OP's problem?