ack is a tool like grep, aimed at programmers with large trees of heterogeneous source code.
ack is written purely in Perl, and takes advantage of the power of Perl’s regular expressions.
File mass replace
Use the sed -i command
sed -i.BAK 's|foo|bar|g' files # -i does in-place replacement
perl -pi.bak -e 's|foo|bar|g' files # or
perl -pi.bak -e 's|foo|bar|g' `find /pathname -name "filespec"`
Perl is the preferred way, but on some production system you must use the old good sed. For some tips on sed take a look to its faq.
Another very powerful command is xargs. Xargs is a rapid way to process files containing spaces, using a combo with find:
find . -print0 -type f | xargs -0 ls | grep " "
Xargs is normally fastest then relaying on backtick substitution. For instance:
ls $(find . -type f)
is slower then
find . -type f | xargs ls
because this second form create two process which works at the same time, using the unix pipe.