Osx find command man
SEE VIDEO BY TOPIC: Terminal Lesson Mac OSX get to know commands to get to advance CLIContent:
This file documents the GNU utilities for finding files that match certain criteria and performing various operations on them. This file documents the GNU utilities for finding files that match certain criteria and performing various actions on them. This manual shows how to find files that meet criteria you specify, and how to perform various actions on the files that you find. The principal programs that you use to perform these tasks are find , locate , and xargs.
Some of the examples in this manual use capabilities specific to the GNU versions of those programs. Many other people have contributed bug fixes, small improvements, and helpful suggestions.
Reporting bugs this way means that you will then be able to track progress in fixing the problem. The mailing list bug-findutils gnu. To join the list, send email to bug-findutils-request gnu. Please read any relevant sections of this manual before asking for help on the mailing list. If you ask for help on the mailing list, people will be able to help you much more effectively if you include the following things:. It may also be the case that the bug you are describing has already been fixed, if it is a bug.
If you take the time to check that your bug still exists in current releases, this will greatly help people who want to help you solve your problem. For brevity, the word file in this manual means a regular file, a directory, a symbolic link, or any other kind of node that has a directory entry. A directory entry is also called a file name. A file name may contain some, all, or none of the directories in a path that leads to the file.
A directory tree is a directory and the files it contains, all of its subdirectories and the files they contain, etc. It can also be a single non-directory file. Actions that you might want to perform on the files you have found include, but are not limited to:. The principal programs used for making lists of files that match given criteria and running commands on them are find , locate , and xargs.
An additional command, updatedb , is used by system administrators to create databases for locate to use. It is run like this:. Here is a typical use of find. Notice that the wildcard must be enclosed in quotes in order to protect it from expansion by the shell. The system administrator runs the updatedb program to create the databases. Which file names are stored in the database depends on how the system administrator ran updatedb.
Most often, these arguments are lists of file names generated by find. The expression that find uses to select files consists of one or more primaries , each of which is a separate command line argument to find. An expression can contain any of the following types of primaries:. See Combining Primaries With Operators , for ways to connect primaries into more complex expressions.
Options take effect immediately, rather than being evaluated for each file when their place in the expression is reached. Therefore, for clarity, it is best to place them at the beginning of the expression. Many of the primaries take arguments, which immediately follow them in the next command line argument to find. Some arguments are file names, patterns, or other strings; others are numbers. Numeric arguments can be specified as. By default, find prints to the standard output the names of the files that match the given criteria.
See Actions , for how to get more information about the matching files. Here are ways to search for files whose name matches a certain pattern. See Shell Pattern Matching , for a description of the pattern arguments to these tests. True if the base of the file name the path with the leading directories removed matches shell pattern pattern. As of findutils version 4. True if the entire file name, starting with the command line argument under which the file was found, matches shell pattern pattern.
These paths are often not absolute paths; for example. True if the entire file name matches regular expression expr. This is a match on the whole path, not a search. For example, to match a file named. This option is positional; that is, it only affects regular expressions which occur later in the command line.
If this option is not given, GNU Emacs regular expressions are assumed. Currently-implemented types are. Regular expressions compatible with GNU Emacs; this is also the default behaviour if this option is not used. Regular Expressions for more information on the regular expression dialects understood by GNU findutils.
To search for files by name without having to actually scan the directories on the disk which can be slow , you can use the locate program. For each shell pattern you give it, locate searches one or more databases of file names and displays the file names that contain the pattern.
See Shell Pattern Matching , for details about shell patterns. If a pattern is a plain string — it contains no metacharacters — locate displays all file names in the database that contain that string. If a pattern contains metacharacters, locate only displays file names that match the pattern exactly. The exceptions are patterns that are intended to explicitly match the beginning or end of a file name.
The differences are that the locate information might be out of date, and that locate handles wildcards in the pattern slightly differently than find see Shell Pattern Matching.
The file name databases contain lists of files that were on the system when the databases were last updated. The system administrator can choose the file name of the default database, the frequency with which the databases are updated, and the directories for which they contain entries.
Here is how to select which file name databases locate searches. The default is system-dependent. Instead of searching the default file name database, search the file name databases in path , which is a colon-separated list of database file names.
The option overrides the environment variable if both are used. GNU locate can read file name databases generated by the slocate package. However, these generally contain a list of all the files on the system, and so when using this database, locate will produce output only for files which are accessible to you.
The updatedb program can also generate database in a format compatible with slocate. A shell pattern is a string that may contain the following special characters, which are known as wildcards or metacharacters. You must quote patterns that contain metacharacters to prevent the shell from expanding them itself. Double and single quotes both work; so does escaping with a backslash. Matches exactly one character that is a member of the string string. This is called a character class. As a shorthand, string may contain ranges, which consist of two characters with a dash between them.
Removes the special meaning of the character that follows it. This works even in character classes. This is also the case for locate.
Slash characters have no special significance in the shell pattern matching that find and locate do, unlike in the shell, in which wildcards do not match them. There are two ways that files can be linked together. Symbolic links are a special type of file whose contents are a portion of the name of another file. Hard links are multiple directory entries for one file; the file names all have the same index node inode number on the disk.
Symbolic links are names that reference other files. GNU find will handle symbolic links in one of two ways; firstly, it can dereference the links for you - this means that if it comes across a symbolic link, it examines the file that the link points to, in order to see if it matches the criteria you have specified.
Secondly, it can check the link itself in case you might be looking for the actual link. If the file that the symbolic link points to is also within the directory hierarchy you are searching with the find command, you may not see a great deal of difference between these two alternatives. By default, find examines symbolic links themselves when it finds them and, if it later comes across the linked-to file, it will examine that, too.
In this situation, find uses the properties of the link itself. This also occurs if a symbolic link exists but points to a file that is missing. This is the default behaviour.
This option must be specified before any of the file names on the command line. If a symbolic link cannot be dereferenced, the information for the symbolic link itself is used. This will delete empty directories. This option is deprecated.
True if the file is a symbolic link whose contents match shell pattern pattern. See Shell Pattern Matching , for details about the pattern argument. So, to list any symbolic links to sysdep.
Hard links allow more than one name to refer to the same file. This is useful because hard links cannot point outside a single filesystem, so this can cut down on needless searching. Hence you are searching for other links hard or symbolic to the file pointed to by name. You can also search for files by inode number.
How to Search Man Pages at the Command Line
A man page short for manual page is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs including library and system calls , formal standards and conventions, and even abstract concepts. A user may invoke a man page by issuing the man command. By default, man typically uses a terminal pager program such as more or less to display its output.
The primaries can be combined using the following operators. The operators are listed in order of decreasing precedence. The special characters used by find are also special characters to many shell programs. As there is no delimiter separating options and file names or file names and the expression, it is difficult to specify files named -xdev or!.
Finding Files from the Command Line
In Unix-like and some other operating systems , find is a command-line utility that locates files based on some user -specified criteria and then applies some requested action on each matched object. It initiates a search from a desired starting location and then recursively traversing the nodes directories of a hierarchical structure typically a tree. The possible search criteria include a pattern to match against the filename or a time range to match against the modification time or access time of the file. By default, find returns a list of all files below the current working directory , although users can limit the search to any desired maximum number of levels under the starting directory. The related locate programs use a database of indexed files obtained through find updated at regular intervals, typically by cron job to provide a faster method of searching the entire file system for files by name. The two options control how the find command should treat symbolic links. The default behaviour is never to follow symbolic links. The -L flag will cause the find command to follow symbolic links.
Keyboard shortcuts in Terminal on Mac
I needed a solution to create a directory listing backup for my external hard drives. From Debian, I already knew the tree command which lists a directory structure recursively. To install command line tools like the tree command on Mac, you can use the Homebrew package manager as well. You can read here how to install Homebrew. Now you can test the tree command and see what you can do with the tree tool by executing the command tree — help.
I've always wanted to know how to use find, but although I've learned many other Unix commands, it looked a little daunting. I don't use "find" that often, so whenever I need to use it with some arguments e. That "find" command will take forever!
find(1) - Linux man page
This file documents the GNU utilities for finding files that match certain criteria and performing various operations on them. This file documents the GNU utilities for finding files that match certain criteria and performing various actions on them. This manual shows how to find files that meet criteria you specify, and how to perform various actions on the files that you find.
Today's Posts. Quick Links. Search Forums. Show Threads. Show Posts.
Subscribe to RSS
Is it some kind of arcane knowledge, handed down only to initiates after grueling initiations? Well, no. Actually, anyone can learn about Terminal commands, if they know where to look. The key to Terminal wisdom is the man command. In fact, man itself is a command, whose role is to format and display this documentation. Then, if you type man pwd , for example, Terminal will display the man page for the pwd command. All man pages have a common format.