Find a file by filename

If you wanna find a file by filename on osx, you can simply use spotlight to locate and open it. However sometimes you want to also know the folder or path of such file. I am not sure how to do that in spotlight or preview but the following command will help.

find ~ -iname "my_file.png"

The command above will look for my_file.png in your home directory (i.e. ~) and print out the full path of it.

[Update May 15th, 2014] It turns out there is also this command called mdfind that does the spotlight search.

mdfind my_file.png
myfind -onlyin ~/Documents my_file.png

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s