Forrest logo
back to the mdfind tool

mdfind:tldr:52a0d

mdfind: Find a file containing a string, in a given directory.
$ mdfind -onlyin ${directory} "${query}"
try on your machine

The command mdfind -onlyin ${directory} "${query}" is used to search for files or documents that match a specific search query within the specified directory. Here is a breakdown of the command: - mdfind: This is a command-line utility on macOS that allows you to find files based on different attributes such as file name, content, or metadata. - -onlyin ${directory}: This option specifies the directory in which the search should be performed. You need to replace ${directory} with the actual path of the directory you want to search in. - "${query}": This is the search query that specifies the criteria for finding files. The query can be a simple string or a more complex query using boolean operators, metadata attributes, and keywords. The query should be enclosed in double quotes. For example, if you want to search for all text files within the "Documents" folder that contain the word "apple," you would use the following command: ``` mdfind -onlyin ~/Documents "apple"

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the mdfind tool