Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Searching On A Mac

Posted on 2014-01-22
19
Medium Priority
?
251 Views
Last Modified: 2014-02-11
Hi, is it possible to search a full folder of files and sub folders, for a particular word that is in a file.

For example, i am trying to find a file that contains a function in a line of code for a client and i can't seem to locate which file it is in. I have the client's site in a folder with about 200 files (mixture of php, html, js, css) and sub folders.

Is it possible to search for a string at the top level of the folder? Thanks in advance.
0
Comment
Question by:oo7ml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
  • +3
19 Comments
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 600 total points
ID: 39799864
If you open a new finder window and enter a search term, it will search that term in both the file contents and file name.  If you need to be more specific, you can click the plus sign int he finder window (right side under the "save" and you will expose a couple of drop downs that can help you narrow your search.
0
 
LVL 34

Assisted Solution

by:Big Monty
Big Monty earned 200 total points
ID: 39799886
here is a visual representation to use the Find command

http://support.apple.com/kb/ht2350
0
 
LVL 53

Assisted Solution

by:strung
strung earned 200 total points
ID: 39799888
There is an Apple KB with a comprehensive explanation of how do use Spotlight to search:

http://support.apple.com/kb/ht2531
0
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
LVL 53

Expert Comment

by:strung
ID: 39799896
0
 

Author Comment

by:oo7ml
ID: 39799900
Hi, i have tried this and it does not work for me... let's say a html file has the following line of code

<div class="redbox">

Finder doesn't seem to be able to pick up that line in my website folder, however i know it is there?
0
 
LVL 34

Expert Comment

by:Big Monty
ID: 39799903
do you have finder pointing to your website folder?
0
 
LVL 41

Assisted Solution

by:Eoin OSullivan
Eoin OSullivan earned 600 total points
ID: 39799912
Personally I don't trust the Spotlight search for in-file content it is SLOW and inaccurate.

Instead get your hands on this FREE OSX application called EasyFind
http://www.devontechnologies.com/products/freeware.html

It can search for filenames, or text in files .. you can restrict your search to specific folders, include/exclude hidden files and more.

More importantly it is FAST and accurate .. the guys who develop it specialise in document management systems so they know what they are doing.

You can also use the great FREE text editor TextWrangler which has multi-file search and wildcard grep support and it is also good for code editing
http://www.barebones.com/products/textwrangler/

The other option is to use the UNIX find command with a grep or awk parameter but it is not the most intuitive or easy to visualise the results.
0
 
LVL 53

Expert Comment

by:strung
ID: 39799920
The quotes may be confusing it.  Try a boolean search like:

"div class=" and "red box"

http://support.apple.com/kb/PH4332?viewlocale=en_US
0
 
LVL 53

Expert Comment

by:strung
ID: 39799926
Better still, download the freeware Textwrangler:  http://www.barebones.com/products/textwrangler/

It will allow you to search a particular folder for specific text in a file and will even allow you to do a global search and replace on all files in the folder.
0
 
LVL 53

Expert Comment

by:strung
ID: 39799929
Just beat me to it, Eoin!   :-)
0
 

Author Comment

by:oo7ml
ID: 39799934
Cool, thanks guys, appreciate the help... will try this as soon as i get home, thanks
0
 
LVL 41

Expert Comment

by:Eoin OSullivan
ID: 39799962
Spotlight is OK for searching by the filename only and only within your user home folder .. for system or hidden files, contents of ZIP archives or text within files it is hard to beat EasyFind.  Every OSX user should have it in their utility belt.

TextWrangler is your best bet if you want to edit the files after you've searched for them .. it is quite a good web editor and the text search is reliable.
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39799963
>visual representation to use the Find command

Big M, what year are we in now?  Or should I say decade?  :)

oo7ml, the finder does all of this.  I agree spotlight is sketchy.  I use finder all the time for the very same thing.   You do want to make sure you are searching in the correct folder.  Towards the top you have a choice.  Sometimes it does help to be in the folder you actually need rather then the top level.  

Try going to a page, copy some text you want to search for, then paste to the finder (not spotlight) and see what happens.
0
 
LVL 41

Expert Comment

by:Eoin OSullivan
ID: 39799975
padas > the ability of spotlight to search for html type code in a series of nested folders can be a "disaster".  If you want to search a folder and all its subfolders for something like "class='redbox'" I'd never trust spotlight to get it correct whereas I would trust TextWrangler or EasyFind
0
 

Author Comment

by:oo7ml
ID: 39799978
Thanks, i have found it does work well if you click into the folder you are searching for and then work from there.
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39800011
eoinosullivan, I agree, I said spotlight is sketchy.   I never knew (bothered to look) that TextWrangler would find other files.   But it would just use the finder info.  If you happen to work in TW, that is probably a good choice for you.  Outside of that, finder does the trick.

oo7ml, glad you figured it out.
0
 
LVL 53

Expert Comment

by:strung
ID: 39800130
TW will also let you a global search and replace of all occurrences of a phrase inside all files in the folder, so, for instance, 007 could with one keystroke do a global replace of all instances of <div class="red box"> with <div class="green box">.
0
 
LVL 30

Assisted Solution

by:serialband
serialband earned 400 total points
ID: 39802092
OSX is based on NeXT, which is based on BSD unix, so you can also use the good old fashioned, built-in, unix/linux way.  

First, open /Application/Utilities/Terminal.app

If you're looking in the user's Downloads folder, then run this command line.

Search all files recursively with -R option in /Users/007ml/Downloads.
cd /Users/007ml/Downloads/
grep -R "search string" *


Here's another example to narrow the search to all files ending with txt, js, css, or html within the user's Documents folder.
grep -R "search string" /Users/007ml/Downloads/*{txt,js,css,html}


Another example for searhing files that have a single digit number before the file extension.
grep -R "search string" /Users/007ml/Downloads/*[0-9].*{txt,js,css,html}


Unix was built for searching and manipulating text.  Once you find what you're searching for, you can swap terms with sed or awk.
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39802743
This year, I am going to learn to use terminal!
0

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question