Solved

Searching On A Mac

Posted on 2014-01-22
19
232 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 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 150 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 33

Assisted Solution

by:Big Monty
Big Monty earned 50 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 50 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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 33

Expert Comment

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

Assisted Solution

by:Eoin OSullivan
Eoin OSullivan earned 150 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 40

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 52

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 40

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 52

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 29

Assisted Solution

by:serialband
serialband earned 100 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 52

Expert Comment

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

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to count occurrences of each item in an array.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

696 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