Man page unix find
SEE VIDEO BY TOPIC: Linux man command summary with examplesContent:
Linux and Unix find command tutorial with examples
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.
man command in Linux with Examples
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.
Manpage is an abbreviation for manual page, Unix and Linux help documentation files. There are man pages for just about every Unix command line and utility command. To view a man page from a command line you simply enter man followed by the command. For example,. Manpages are stored in nroff format, which is a type of plain text with formatting information to indicate when text should be bold or in a particular colour.
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. They begin with name the name of the command and a brief description of what it does. The pwd command I looked at above shows the following:. Next comes synopsis , which shows the command any any options, or flags, that you can use with it.
Master the command line: How to use man pages
Nearly every aspect of the UNIX operating system is described in online documentation called " manual pages ". But finding the information you need and making sense out of it can be difficult tasks, even for experienced UNIX users. This page offers a basic explanation of how to search for, find, and use manual pages. The manual pages are typically grouped into eight numbered sections and several lettered sections. The numbered sections are the same on most UNIX systems, but the lettered ones vary.
Want to link to this manual page? Skip site navigation 1 Skip section navigation 2 Header And Logo. Peripheral Links. Donate to FreeBSD.
find(1) [v7 man page]
Search a folder hierarchy for filename s that meet a desired criteria: Name, Size, File Type - see examples. GNU find searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence see Operators , until the outcome is known the left hand side is false for AND operations, true for OR , at which point find moves on to the next file name. The -H, -L and -P options control the treatment of symbolic links. That argument and any following arguments are taken to be the expression describing what is to be searched for.
FreeBSD Manual Pages
On Unix-like operating systems, the find command searches for files and directories in a file system. Within each directory tree specified by the given path s, it evaluates the given expression from left to right, according to the rules of precedence see " Operators ", below until the outcome is known. At that point find moves on to the next path until all path s have been searched. It can be used on its own to locate files, or in conjunction with other programs to perform operations on those files. The -H , -L and -P options control the treatment of symbolic links. Arguments following these are taken to be names of files or directories to be examined, up to the first argument that begins with " - ", or the argument " " or "! That argument and any following arguments are taken to be the expression describing what is being searched.
To use the find command, at the Unix prompt, enter:. Leave the double quotes in. The find command will begin looking in the starting directory you specify and proceed to search through all accessible subdirectories. You may specify more than one starting directory for searching.
Save a Unix manpage as plain text
Linux find command