Grin: A smarter way to grep code

  • My preferred programmers grep: http://petdance.com/ack/

    Though rkern is a very clever fellow, and I'm sure grin is sufficiently awesome. I think I'll benchmark the two...I kinda suspect ack is faster, but maybe Python will surprise me (when I used to work in Python a few years ago, I was occasionally disappointed in its performance for tasks like this).

    Interestingly, grin uses the exact same output format as ack...same colors and all.

    And, yep, ack is quite a bit faster:

        $ time ack joe
        real    0m1.708s
        user    0m1.308s
        sys     0m0.348s
    
        $ time grin -d .svn joe
        real    0m6.066s
        user    0m5.191s
        sys     0m0.802s
    
    Looks like grin is trying to deal with things that ack doesn't (binary files, for example), so perhaps that's a factor.

    And, of course, grep (when massaged appropriately to make it only search the bits we really want) is faster still:

        $ time find * -name '.svn' -prune -o -type f -exec grep joe \{\} +
        real    0m0.412s
        user    0m0.149s
        sys     0m0.189s
    
    So, theoretically, one could wrap that up in an alias, but ack is sufficiently fast, and does enough other cool tricks that I'll just stick with it.

  • I don't understand why a new program was created when a shell alias would suffice. I have a set of grep commands aliased in my .bashrc such that I get the features the author described.

    For example:

      alias g="grep -R --exclude 'SVN' --include '*.c' ..."
    
    etc

  • Why rewrite ack? It's already blazing fast and easy to customize even if you're not actually a perl head.

  • undefined

  • Is there a way to do syntax-driven wildcard matching of Python code?