views:

73

answers:

6

Does anyone have a good search tool for OS X?

I am looking for a way to search entire large directories for information in files (.g, .cpp. .txt, other txt with different extensions) and then globally replace and manage.

I have a huge code base where I have to do a lot of replacements and XCode is bombing, TextMate cannot handle some large files or large directory scanning, etc.

Does anyone have thoughts?

+1  A: 

I would use perl. It was practically designed for this sort of problem. Here's a guide to getting started with it on OSX.

fatcat1111
+1  A: 

Open a console and type:

man find

The find command should do everything you want.

James Anderson
A: 

not 100% but maybe you could try an editor like smultron? might be able to do what you need

JT.WK
A: 

TextWrangler and its big brother BBEdit have some pretty decent multi-file search and replace tools.

If you just want to search, particularly through source files, ack is terrific.

Nicholas Riley
A: 

Have you tried the Ack in Project bundle for TextMate?

Ned Deily
+2  A: 

You should try find. For example, if you want to search for a file called lost_file but you are not sure about the extension, then use

$ find . -type f -name lost_file.*

It will find lost_file.c, lost_file.cpp, etc. The parameters are:

  • -type f: f directs find to search for files (not directories),
  • -name lost_file: search criteria

You can also use xargs to perform some command over the files.

Of course, as you are using OSX, you should try spotlight (Command+Space).

Last example, to delete every directory called .svn from a directory tree, use:

$ find . -type d -name .svn | xargs rm -rf
licorna
Good answer. An alternative to xargs is the -exec arg to find. The .svn example could also be written as: find . -type d -name .svn -exec rm -rf '{}' \;
overthink