Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to find a file on my macbook with the filename "abc.dmg". I've tried to use spotlight, but it doesn't find it. I've tried find (find -name abc.dmg -path /) but get errors back.

What is the proper syntax on a Mac?

share|improve this question
    
@VxJasonxV Apple questions are 100% on topic for Super User, and no real need to have every Apple question moved there. iPhone or iPad questions however will be moved when/if required. –  Diago Dec 28 '10 at 22:57
    
It wasn't so much a reason of being off-topic, but the fact that there is a more specific topic/site for this general subject. –  VxJasonxV Dec 28 '10 at 23:57
    
@Diago: Has there been any discussion regarding this on meta or chat? Just wondering because AFAIK apple.SE will be launching out of beta pretty soon, so it would be nice to get everyone on the same page. –  Robert S Ciaccio Dec 29 '10 at 0:19
    
@calavera. Fairly old discussion but relevant can be found here. Apple SE, Ubuntu SE and Linux SE is all there to compliment Super User, but in no way do we want to force users to move. I prefer asking my Apple questions here rather then Apple, since I do use 3 different operating systems. If I have a very specific question, I will ask it on a more specialized site. –  Diago Dec 29 '10 at 7:22
add comment

4 Answers

up vote 12 down vote accepted

In it's simplest form, find takes one parameter, the path, in it's actually worthful form, it takes the path, and then narrowing criteria.

Thus, you want, find (the program), / (the path), and -name abc.dmg (the criteria).

find / -name abc.dmg

share|improve this answer
2  
You may get permission denied type errors when searching the entire drive but they can be ignored unless you expect the file to be in a restricted folder. If so use sudo find / -name abc.dmg –  Chris Nava Dec 28 '10 at 18:31
    
Tried it, but no result. –  rxt Dec 28 '10 at 18:55
2  
Presumably then, you don't have a file named abc.dmg on your computer. You can use -iname instead of -name to make the search case insensitive. I highly doubt you're actually searching for "abc.dmg", and given that (presumably) fact, it's hard to tell you what your issue is without having the actual details. –  VxJasonxV Dec 28 '10 at 19:18
1  
@rxt: if find dooesn't find it, it's not there... –  Robert S Ciaccio Dec 28 '10 at 19:37
1  
Given that OP report have tried find in the question text, it is worth noting that the order of the arguments to find matters. If must be find [path]+ [selection, grouping, and actions]. –  dmckee Dec 28 '10 at 22:21
show 1 more comment

You can use the locate command.

locate abc.dmg
share|improve this answer
    
Note the osx tag. slocate db doesn't populate by default. –  VxJasonxV Dec 28 '10 at 17:46
    
Tried it, after creating the database, but no result. –  rxt Dec 28 '10 at 18:56
    
if locate and mdfind both fail, chances are the file isn’t on your machine. Or its not named how you think its named. perhaps searching for ALL DMGs may be your next step? –  peelman Dec 28 '10 at 19:20
add comment

The simplest way (which I'm sure you've already tried, but hey, let me add it to the thread anyway) is to enter abc.dmg into the search box on the top right of any finder window, then select "File Name" from the options on the Search Bar that appears.

No need for the terminal.

Also remember that Spotlight only indexes directories specified in the Spotlight control panel and abc.dmg may not be in one of those directories.

Correct me if i'm wrong, but i think the find command needs to know what to output:

find / -name abc.dmg -print

...should print any results to the terminal (including permission errors).

If you don't want permission errors and want to search other User directories then:

sudo find / -name abc.dmg -print
share|improve this answer
add comment

The mdfind command uses the Spotlight database

http://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/mdfind.1.html

share|improve this answer
    
But Spotlight doesn't find it, per the OP's original question. –  VxJasonxV Dec 28 '10 at 19:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.