Searching for files with the Find command
The find command is very efficient and simple to use. The find command from Unix,os X and Linux systems also supports this command. The most basic operation of find is:
Find File Path parameter
Copy Code
For example, you can use the following command to search the user folder for the file containing screen in the name
Find ~-iname "screen*"
Copy Code
You can also find specific files in a specific folder, such as
Find ~/library/-iname "Com.apple.syncedpreferences.plist"
Copy Code
This command can find the Com.apple.syncedpreferences.plist file in the Library folder.
Searching for files with the Mdfind command
The Mdfind command is the terminal interface of the spotlight feature, which means that Mdfind commands will not work if spotlight is disabled. The Mdfind command is fast and efficient. The most basic ways to use this are:
Mdfind-name file name
Copy Code
For example, you can search for a photo 1.PNG file using the following command
Mdfind-name "Photo 1.PNG"
Copy Code
Because Mdfind is the terminal interface for Spotlight functionality, you can also use Mdfind to find the contents of files and folders, such as searching for all files containing will Pearson text with the following command:
Mdfind "would Pearson"
Copy Code
The Mdfind command also allows you to search the contents of a specific folder through the-onlyin parameter, such as
Mdfind-onlyin ~/library plist
Copy Code
This command can search all the plist files in the Library folder.
Mac Find command