Find man page bash
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.SEE VIDEO BY TOPIC: Troff Tutorial: How To Write A Linux Man Page With Troff
SEE VIDEO BY TOPIC: Mastering Linux Man Pages - A Definitive GuideContent:
Bash Reference Manual
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. If no path s are given, the current directory is used. If no expression is given, the expression -print is used but you should probably consider using -print0 instead, anyway. More information on this below. The arguments in the expression list are also referred to as "options," but the five "real" options -H , -L , -P , -D and -O must appear before the first path name, if they are used at all.
A double-dash " -- " can also be used to signal that any remaining arguments are not options though ensuring that all start points begin with either ". If more than one of -H , -L and -P is specified, each overrides the others; the last one appearing on the command line takes effect. Since it is the default, the -P option should be considered to be in effect unless either -H or -L is specified. GNU find frequently stat s files during the processing of the command line itself, before any searching has begun.
These options also affect how those arguments are processed. Specifically, there are a number of tests that compare files listed on the command line against a file we are currently considering. In each case, the file specified on the command line will have been examined and some of its properties will have been saved. If the named file is in fact a symbolic link, and the -P option is in effect or if neither -H nor -L were specified , the information used for the comparison will be taken from the properties of the symbolic link.
Otherwise, it will be taken from the properties of the file the link points to. If find cannot follow the link for example because it has insufficient privileges or the link points to a nonexistent file the properties of the link itself will be used. When the -H or -L options are in effect, any symbolic links listed as the argument of -newer will be dereferenced, and the timestamp will be taken from the file to which the symbolic link points.
The same consideration applies to -newerXY , -anewer and -cnewer. The -follow option has a similar effect to -L , though it takes effect at the point where it appears that is, if -L is not used but -follow is, any symbolic links appearing after -follow on the command line will be dereferenced, and those before it will not.
Print diagnostic information; this can be helpful to diagnose problems with why find is not doing what you want. The list of debug options should be comma separated.
Compatibility of the debug options is not guaranteed between releases of findutils. For a complete list of valid debug options, see the output of find -D help.
Valid debug options include:. Enables query optimisation. The find program reorders tests to speed up execution while preserving the overall effect; that is, predicates with side effects are not reordered relative to each other. The optimisations performed at each optimisation level are as follows.
There must not be a space in between -O and the decimal representing the optimization level. The decimals and their meanings are as follows:. The expression is made up of options which affect overall operation rather than the processing of a specific file, and always return true , tests which return a true or false value , and actions which have side effects and return a true or false value , all separated by operators.
If the expression contains no actions other than -prune , -print is performed on all files for which the expression is true. All options always return true. Except for -daystart , -follow and -regextype , the options affect all tests, including tests specified before the option. This is because the options are processed when the command line is parsed, while the tests don't do anything until files are examined. The -daystart , -follow and -regextype options are different in this respect, and have an effect only on tests which appear later in the command line.
Therefore, for clarity, it is best to place them at the beginning of the expression. A warning is issued if you don't do this. Some tests, for example -newerXY and -samefile , allow comparison between the file currently being examined and some reference file specified on the command line. When these tests are used, the interpretation of the reference file is determined by the options -H , -L and -P and any previous -follow , but the reference file is only examined once, at the time the command line is parsed.
If the reference file cannot be examined for example, the stat system call fails for it , an error message is issued, and find exits with a nonzero status. Compares the timestamp of the current file with reference. The reference argument is normally the name of a file and one of its timestamps is used for the comparison but it may also be a string describing an absolute time. X and Y are placeholders for other letters, and these letters select which time belonging to how reference is used for the comparison.
Returns true if a file uses n units of space on the disk. The following suffixes can be used to abbreviate units:. Field widths and precisions can be specified as with the ' printf ' C function. This also means that the ' - ' flag does work it forces fields to be left-aligned. Unlike -print , -printf does not add a newline at the end of the string.
The escapes and directives are:. The file's last access time in the format specified by k , which is either ' ' or a directive of the C ' strftime ' function. The possible values for k are listed below; some of them might not be available on all systems, due to differences in strftime between systems. In some locales, it may hide your door keys, while in others it may remove the final page from the novel you are reading.
Numeric directives that do not support these flags include G , U , b , D , k and n. The ' - ' format flag is supported and changes the alignment of a field from right-justified which is the default to left-justified.
Many of the actions of find result in the printing of data that is under the control of other users. This includes file names, sizes, modification times and so forth. Unusual characters in file names can do unexpected and often undesirable things to your terminal for example, changing the settings of your function keys on some terminals.
Unusual characters are handled differently by various actions, as described below:. When using linux, running the find command without any options will locate and print a list of every file in and beneath the current directory. This includes all files in all subdirectories of the current directory. Same as the above command. The ".
Locate and print a list of any file in or below the current directory whose name is exactly " apple ", all lower case letters. Locate and print a list of any file in or below the current directory whose name is " apple ", but match the letters case-insensitively. Locate and print a list of files in or below the current directory whose name is " apple "; do not display directories, sockets, or other non-regular file types.
Locate a print a list of directories in or below the current directory whose name is " apple "; do not display regular files, or file types other than directory entries. Locate and print a list of any file in or below the current directory whose owning group is the dev group.
Locate and print a list of any file in or below the current directory, and follow symbolic links. In other words, display information about the file a symbolic link links to, rather than information about the symlink itself. Locate and print a list of any file in or below the current directory that was last accessed more than 1 day ago. Locate and print a list of any file in or below the current directory that was last accessed less than 1 day ago. Locate and print a list of any file in or below the current directory that was modified more than 5 minutes ago.
Locate and print a list of any file in or below the current directory that was modified fewer than 5 minutes ago. Locate and print a list of any file in or below the current directory whose octal permission bits are user can read, write, and execute; owning group members can read and execute; others can read only. For more information about permission bits, see chmod.
Same as the above command, but uses a symbolic representation of the permission bits. Note that the symbolic notation uses a comma separator and contains no spaces. Locate and print a list of any regular file in or below the current directory whose size is greater than 1 megabyte. Locate and print a list of any regular file in or below the current directory whose size is less than 5 gigabytes.
Locate and print a list of any file or directory in or below the current directory owned by the user jeff. Locate any files in or below the current directory whose size is greater than 1 gigabyte, and exec ute the mv command on them, moving them into the directory bigfiles in your home directory.
Locate any files in or below the current directory whose size is greater than 1 gigabyte, then pipe that list to the xargs command, which uses the mv command to move each one of those files into the directory bigfiles in your home directory. This is similar to the above command, but better for several reasons. First, it uses the -print0 option to tell find to create its list separating each file name with a null character rather than a newline ; this makes the list difficult for a human to read, but has the advantage of making it easier for another program to parse.
You should always use -print0 when piping output to xargs. Using xargs to execute commands on every file found is generally better than using find 's -exec option because of the more efficient way xargs threads each command that it spawns. The -0 argument to xargs tells it to expect the null character as the file name separator which we specified with find 's -print0 option.
We enclose it in single quotes to protect it from the shell. Using -ok is the same as using -exec , but you will be asked for confirmation before each command is executed. Locate any files in or below the current directory whose suffix is ".
The -o option functions as a boolean OR operator; if either of the conditions are true, the file will be included in the list. Any subdirectories 3 or more levels deep will not be searched.
Locate any files in or below the current directory whose suffix is not ". The exclamation mark "!
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.
Linux find command
man command in Linux with Examples
Section-num : Since a manual is divided into multiple sections so this option is used to display only a specific section of a manual. So this option gives the section in which the given command is present. In this example you can move through the manual pages sections i. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Published: Author: Remy van Elst Text only version of this article. Bash Bits are small examples, tips and tutorials for the bash shell. This bash bit shows you that find has a -delete option. This is shorter and easier to remember.
man command in Linux with Examples
The Linux command line offers a wealth of power and opportunity. If your memory is like mine then you find it hard to remember a large number of details. Fortunately for us there is an easy to use resource that can inform us about all the great things we can do on the command line.
Manual pages are the canonical type of documentation for Unix systems. They are a bit arcane, but for a technology several decades old, they've held up quite well. The arcane bit is the markup language. This is a brief tutorial on writing good manual pages, at least for the typical cases. You'll be assumed to be familiar with reading manual pages already. There are actually many ways to produce manual pages.
Subscribe to RSS
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.
This text is a brief description of the features that are present in the Bash shell version 5. This is Edition 5. Bash contains features that appear in other popular shells, and some features that only appear in Bash.
Скрытые тенью, на него смотрели глаза Грега Хейла, глаза, полные ужаса. Тогда Стратмор понял, что Грег Хейл должен умереть. В ТРАНСТЕКСТЕ послышался треск, и Стратмор приступил к решению стоявшей перед ним задачи - вырубить электричество. Рубильник был расположен за фреоновыми насосами слева от тела Чатрукьяна, и Стратмор сразу же его .
Игра в шарады закончилась.
Беккер кивнул, плохо соображая, какая тут связь. - Такая прическа была у Табу в день гибели. - Парень снова сплюнул. - Поэтому все его последователи, достойные этого названия, соорудили себе точно такие. Беккер долго молчал.
Сьюзан никогда не видела этого человека раньше. Подойдя вплотную, незнакомец буквально пронзил ее взглядом. - Кто это? - спросил. - Сьюзан Флетчер, - ответил Бринкерхофф. Человек-гигант удивленно поднял брови.
И что особенно удачно - эту компанию меньше всего можно было заподозрить в том, что она состоит в сговоре с американским правительством. Токуген Нуматака воплощал старую Японию, его девиз - Лучше смерть, чем бесчестье. Он ненавидел американцев. Ненавидел американскую еду, американские нравы, но более всего ему было ненавистно то, что американцы железной хваткой держали мировой рынок компьютерных программ.