What's the best tool or method to search for a specific word in a codebase?

Take a look at ack which is designed for searching big codebases For replacing, look at Perl's -i, -p and -e flags. You can do stuff like: $ perl -i -p -e's/\bthisword\b/thatword/g' $(find . -name *.

Html) to replace all instances of thisword with thatword in all . Html files in the tree.

Take a look at ack, which is designed for searching big codebases. For replacing, look at Perl's -i, -p and -e flags. You can do stuff like: $ perl -i -p -e's/\bthisword\b/thatword/g' $(find .

-name *. Html) to replace all instances of thisword with thatword in all . Html files in the tree.

You could also use ack for the find part in your replace example: $ perl -i -p -e's/\bthisword\b/thatword/g' $(ack -f --html) – user55400 Feb 13 '09 at 14:38.

I'm assuming you intend to rename a variable. It depends on what the body of code is. For C#, Visual Studio's renaming tool is very good.

Remember that for it to work reliably, you need the renaming to work hand in hand with the compiler/interpreter, so you can make sure you only make the change in the right scope. If it is a very simple find/replace, surely the lowly notepad would do an OK job?

Find and grep will find the word you're looking for, but to replace it you need to use sed, awk or your favorite stream editing filter. Groovy, python, perl will all do search/replace operations - use your favorite or pick one to learn. For operations on a code base, I'll use find | sed for simple operations (cygwin is your friend) and the IDE's search/replace with regex support for more complex operations.

Eclipse, Idea, Visual Studio and even SQL Server Manglement Studio have powerful search/replace functions. The bad news is that not all of them use the same regex syntax.

Take a look into PowerGrep... it has ads everywhere in SO. I'm starting to want it even when I don't really need it- PD: They have a 15 days free demo, so if this is a small job you could just use the demo.

This is just a tip to Andy's above accepted answer. Could not add this as a comment due to less reputation Use! As a seperator when you have tough time escaping the strings e.

G $ perl -i -p -e's! \bthisword\b! Thatword!

G' $(find . -name *. Html).

Find and grep don't build indecies, so they're always going to be slower than alternatives that do. That said, they work fine if your codebase is only a few dozen files. In Fi Eclipse has a nice file search feature (Ctrl+H).

It can also take language semantics into consideration if you have the right plugins (Java works out of the box, of course). The only caveat is that it can be a bit slow the first time you search in a certain file set.

Thanks for using the Search-based Keyword Tool. You'll be redirected to the updated Keyword Tool, which now includes results from the Search-based Keyword Tool.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions