Back when I was using SVN as version control system, there was one annoying thing: SVN stored all versioned files twice. There always was a copy in the .svn directory. So, when I was using
grep -r 'use strict'I also got these copies as results. By typing
grep -r 'use strict' | grep -v .svnI only got the desired results.
It was at this time that I came across ack - and was immediately sold. Ack ignores also other version control directories and common backup files (e. g. ending with '~').
Also, it lets you specify the file types:
ack --perl 'use strict'
There are more options, have a look at the documentation.
Ack is available through CPAN - just install App::Ack. But there is also an standalone version which includes every module into one big script:
curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 !#:3
This standalone version is also used in the ack-in-project and AckMate TextMate bundle. (TextMate is a popular text editor for MacOS.) I use TextMate at work - the AckMate bundle works very well.
Ack runs also on Windows (its pure perl). Under Debian and Ubuntu the package is called ack-grep. (Ack is a Kanji code converter there.)