Question

I am trying to find text within one of bash's setup files on my mac (10.9.2).

I know the text "PIP_RESPECT" is in .bash_profile

I tried Find Any File, which apparently does not search within files.

I rebuilt my spotlight index.

I tried a finder search with visibility set to invisible, with no luck

I tried the following terminal commands:

mdfind "PIP_RESPECT"
mdfind *PIP_RESPECT*
mdfind "*PIP_RESPECT*"
mdfind '"*PIP_RESPECT*"'

which return nothing.

mdfind 'kMDItemTextContent == "*PIP_RESPECT*"cd'

which returns:

~/Library/Application Support/Firefox/Profiles/6wjt9c4s.default/sessionstore.js

which is clearly not the .bash_profile.

So what am I doing wrong?


Thank you for all your responses:

I am just trying to find the text "VIRTUALENVWRAPPER_PYTHON," if it exists, in any file, by any means.

I listed all the things I tried.

@ stakolee:

$ grep 'PIP_RESPECT' ~/.bash_profile return in the terminal

returned:

~/.bash_profile:export PIP_RESPECT_VIRTUALENV=true grep: return: No such file or directory grep: in: No such file or directory grep: the: No such file or directory grep: terminal: No such file or directory

so the top return is what I want, thank you. I would give you a check mark, but it does not seem to allow check marks in comments.

@Mark Setchell

Easy Find finished a lot faster, but you have made me realize I need to learn more about grep.

I awarded the checkmark to:

@ Thomas Tempelmann "find any file guy": sorry, I didn't mean to dis your app, but the Easy Find app did work, after i changed the settings to scan all files

I clearly have more to learn, thank you all, again.

Was it helpful?

Solution

I am not sure from your question if you are trying to say "How do I make Spotlight find a file?" or "I want to find a file containing PIP_RESPECT and I don't care how".

If the second, you can search through every file on your Mac from the terminal like this:

sudo find / -type f -exec grep PIP_RESPECT {} /dev/null \; 2> /dev/null

It will take some time to run! It says... starting at the root (top) of the filesystem, find everything that is a file (not directory) and look in every file (with grep) and see if you can find PIP_RESPECT and print the name of the file if you can and throw away error messages.

If you only want to search in your own login directory and below, it will be quicker and easier to do this (thanks to @I'L'I):

find  ~  -type f -exec ....

OTHER TIPS

Author of Find Any File here.

I tried Find Any File, which apparently does not search within files.

Right, it doesn't. But it documents that clearly both on the web page. May I quote:

Contrary to Spotlight, [...], but not for file content (use Spotlight or EasyFind for that).

And if you read a bit further down:

Alternatives to Find Any File

If you like to search for data inside files, and Spotlight doesn't do it for you, have a look at EasyFind by DEVONtechnologies [...]

If you want to search for specific text in a large set of files inside a directory, I recommend TextWrangler.

Also, the reason why Spotlight (including mdfind) doesn't find anything is that Spotlight implicitly ignores anything in the System folders. It won't ever find anything in there.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top