Wednesday, April 14, 2010

How to ignore version control meta files when grepping????

So you came across the same problem ha!!!.
When you are working with a sufficiently large project it is very essential to search through your code repository. Integrated development environments such as intellijIDEA (my favorite ;-) ) provides searching as a integrated functionality.
But if you are in to C/C++ developing on UNIIX platform your favorite editor going to be vim right? So every now & then you have to search through the repository in order to find the code snippet that you are after. 'grep' is the obvious answer. If your code repository under source control you have to make sure that you avoid those files when you are searching. To search a specific text using 'grep', you have to tell it to search recursively,ignore certain file types, etc.

Now ack-grep is the solution for this sort of situation. It is heavily customized for day to day code searching operations. By default,

  •  it searches recursively from the top level directory.
  •  identifies & ignore almost all the version control meta files.
  •  highlight the search word within the results.
  •  give the number & occurring file of the pattern.
  •  It identifies the file types (weather it is a Java source file or C++ source file) 

So you only have to do:
$>ack-grep 'pattern you want to search'

Here is a simple usage of the tool in one of my source repositories;

In order to install it in Ubuntu, just do a sudo apt-get install ack-grep. This is a very nice tool & i like it......  :) 

No comments:

Post a Comment