Search code examples
gitsearchfindgrepdirectory-tree

How can I search my directory tree for contents within a file for a git managed project?


I like the unix find command but I always find it too 'fiddly' to use when I want to search through my project looking for a piece of text in any file in any directory or subdirectory.
Is there an easier way to do this?


Solution

  • git grep "your text string", from the applcation's base directory is a great way to do this.

    Also as Christopher points out ack is useful.

    His install method didn't work for me. I had to do:

    sudo apt-get install ack-grep
    

    and then for convenience

    alias ack='ack-grep '  # So that I can just type ack "string"
    

    which I'll also add to my ~/.bash_aliases file.