PDA

View Full Version : File content search utility



bkochis
1st January 2008, 06:03 PM
I have an OsCommerce installation and am adding packages, etceteras at home.

I am looking for a utility that will allow me to search a directory of PHP for files containg a specific string such as 'tep_encrypt_password'. I do no care command-line or GUI.
I seem to be running into a lot of 'undefined' errors and am trying to find out where these items were defined in the unmodified original package or add-ons.

Thanks, Bob

rbo83
1st January 2008, 06:49 PM
Are you familiar with grep ?

bkochis
1st January 2008, 06:58 PM
not really. Can I grep an entire directory looking for a text phrase? That would be cool.

mbratch
1st January 2008, 07:59 PM
Do a 'man grep', there's an option to recurse directories.


grep -r _expression_ _dir_

Here's an equivalent method using 'find':


find _dir_ -type f -exec grep _expression_ {} \; -print

Fenrin
19th October 2011, 09:28 PM
nice that I found this thread this command "grep -r _expression_ _dir_" is indeed useful. Even though it has some disadvantages compared to eclipses search utility. But nevertheless I prefer geany and this command instead to use slow PHPEclipse.

Does anyone know any other useful search utility to find expressions in textfiles? In gnome 2 was beagle for this purpose right? Any equivalent program in Gnome 3 yet?

mikereid
19th October 2011, 10:16 PM
Here's an equivalent method using 'find':


find _dir_ -type f -exec grep _expression_ {} \; -print
And this technique can also be used to search for particular files, or file types. I often find this useful when trying to remember where I wrote some code to do some particular task...

The syntax I'm more familiar with is (for searching down from the current directory):


grep _expression_ `find . -iname "*._extension_" -print`

And in practise I have the find coded in a shell script so I can type something short, like:


grep _expression_ `_my_find_script_"*._extension_"`

Mike