Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

GREP


Guest

Recommended Posts

I have been having some problems finding a good tool for searching text in files.

 

The search tool that comes with Microsft Windows XP does not work when searching for strings in files such as PHP. I suppose this is because the tool is designed for users and not programmers and hyperlink text is only search for what a typical user would see when the file is presented in a a browser window.

 

Someone suggested that I use Grep that comes with Cygwin, a Unix emulation program.

 

But that seems to have problems searching subdirectories.

 

Any suggestions?

Link to comment
Share on other sites

Someone suggested that I use Grep that comes with Cygwin, a Unix emulation program.

 

But that seems to have problems searching subdirectories.

 

Any suggestions?

 

find . -name "*.php" -print | xargs grep -i "foo"

 

Commands:

find - find all files starting with a certain location by a certain parameter, and do something with them. In the example above, I am finding files starting within the current directory ("."), searching by name for files like "*.php", and printing them. If you run the first part of the command (before the pipe "|" character), you will see all such files. The "find" command traverses subdirectories!

 

xargs - use the preceding as a set of arguments for the following.

 

grep - standard search in *nix shells. Here, I am looking (-i means case insensitive) for "foo," so I will also hit on "FoO," "fOO," "FOO," etc.

 

Chaining the commands (with the pipe "|") means:

 

Generate a complete list of all files that meet my specifications, and pass this list of filenames as the input to my grep command for "foo."

 

Hope that this helps.

Link to comment
Share on other sites

  • 1 year later...

I need one that works in Windows XP, Also one that searches multiple unopen files in a folder for a string of text like (Temp....) I do not need one to search an open php file.

 

 

I tried Crimson editor and got this error: ---------- Find in Files ----------

> Searching for the string 'button_wishlist.gif'...

> Cannot find the string 'button_wishlist.gif'.

 

Any ideas?

 

Thanks

Link to comment
Share on other sites

I need one that works in Windows XP, Also one that searches multiple unopen files in a folder for a string of text like (Temp....) I do not need one to search an open php file.

 

Any ideas?

 

Thanks

 

Hi Tim! Maybe this one will help: Try using the command prompt and use the findstr command. This command searches a string on a specified file or files. There are a lot of ways and options with this command. For further information - just type help findstr at the command prompt.

 

I tried it with this example. I searched for all the .jsp files containing the "<html>" string using this command:

findstr /s /i /m "html" jsp\*.jsp

 

This performed a non-case-sensitive search(/i) and displayed all the jsp files (/m) which contain the "<html>" string in the specified (jsp) directory and all of its sub-directories (/s).

 

Hope this one would finally solve your problem! :thumbsup:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...