The Computer Oracle

How do I find a file by filename in Mac OSX terminal?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Lost Meadow

--

Chapters
00:00 Question
00:37 Accepted answer (Score 343)
01:07 Answer 2 (Score 64)
01:29 Answer 3 (Score 16)
01:44 Answer 4 (Score 8)
01:56 Thank you

--

Full question
https://superuser.com/questions/226566/h...

Answer 2 links:
http://developer.apple.com/library/mac/d...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #terminal #find

#avk47



ACCEPTED ANSWER

Score 403


In its simplest form, find takes one parameter: the path. In its actually useful form, it takes the path followed by narrowing criteria.

Thus, you want:

  • find (the program)
  • / (the path), and
  • -name abc.dmg (the criteria).
find / -name abc.dmg



ANSWER 2

Score 76


find . -name '*.csv' for instance worked for me with wildcards. OP could also use find . -name '*.dmg' to check his current directory, assuming he was in /.




ANSWER 3

Score 20


The mdfind command uses the Spotlight database

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




ANSWER 4

Score 10


You can use the locate command.

locate abc.dmg