Search code examples
less-unix

How can I efficiently jump to a specific time in a large log?


I have a huge daily textual logs (2-3 GB), which I want to investigate for specific event (which I know when it occurred), I'm using less (since it all on ssh to remote server).

I'm looking for an option to jump as fast as I can to the exact time, and I think if there is an option to a binary search to find it, it should be the fastest (right now jump to end of the day takes tens of seconds)

Thanks!


Solution

  • Based on this other question's answer:
    sgrep might work for you:

    sudo apt-get install sgrep
    sgrep -l '"needle"' haystack.txt
    

    The project page http://sgrep.sourceforge.net/ says:

    Sgrep uses a binary search algorithm, which is very fast, but requires sorted input.