September 19, 2013 Adem Bilican No comments

Alternative to locate/find command line on mac

In linux you can use the “find” or “locate” command to look for a specific file or folder. The best alternative I know on Mac is Spotlight. However Spotligh is based on a graphical interface and the “best” option is to show all the results on the Finder, which is not very handy if you work all the time on the command line. After some research, I found a way to use Spotlight from the command line and show the results as the find or locate command on linux.

The main command to show Spotlight results on the terminal is :

    mdfind -name $NAME

where $NAME is the word you are looking for.

To make it easier to use and remember, I put an alias on my bash
1 – Open the file ~/.bash_profile
2 – Add the following lines

mdfind -name $1
alias find=search

3 – Reload you bash

    source ~/.bash_profile

you can now use the “find $NAME” command within your terminal as you would use it on linux and enjoy the results 😉

Related links :
Bash alias and parameters
Search Spotlight from the osx terminal
Source: New feed

Leave a Reply

Your email address will not be published. Required fields are marked *