Find files in a directory hierarchy (2023)


think[-H] [-L] [-P] [-D debug options] [-Olevel] [startpoint...] [expression]


This manual page documents the GNU version ofthink.FIELDthinksearches the directory tree rooted at each start point and evaluates the given expression from left to right according to the precedence rules (see the OPERATORS section) until the result is known (the left side is false formioperations, true foro), at which pointthinkgoes to the next file name. If no starting point is specified, '.' is assumed.

and usethinkIn an environment where security is important (for example, if you are using it to find directories that other users can write to), you should read the "Security Considerations" chapter of the documentation for findutils that is invoked.find filesand comes with findutils. This document also contains much more detail and discussion than this manual page, so you may find it a more useful source of information.


o-H,-UEmi-PAGEOptions control how symbolic links are handled. Subsequent command line arguments are treated as the names of the files or directories to be examined, up to the first argument beginning with "-" or the "(" or "!" argument. This argument and all The following arguments are considered the expression that describes what to search for. If no path is specified, the current directory is used. If no expression is specified, the expression-pressis used (but you should probably consider using this-print0instead anyway).

This man page talks about `options' within the expression list. These options control the behavior ofthinkbut it is specified immediately after the last pathname. The five "real" options-H,-UE,-PAGE,-Dmimust precede the first route name, if any. a double bar--it can also be used to signal that all remaining arguments are not options (although it is generally safer to ensure that all leading points start with './' or '/' when using wildcards in the list of leading points).

Never follow symbolic links. This is the default behavior. WhenthinkWhen browsing or printing information from a file, and the file is a symbolic link, the information used must be obtained from the properties of the symbolic link itself.
Follow symbolic links. WhenthinkBrowse or print information about files, the information used should be taken from the properties of the file the link points to, and not from the link itself (unless it is a broken symlink orthinkcannot browse the file the link points to). The use of this option implies-no blade.If you then use the-PAGEPossibility,-no bladewill continue to apply. Yeah-UEapplies andthinkfinds a symbolic link to a subdirectory during its search, the subdirectory that the symbolic link points to is searched.
If he-UEthe option is in effect, the- ArtThe predicate always matches the type of file a symlink points to, rather than the link itself (unless the symlink is broken). Actions that can cause symbolic links to breakthinkrunning (eg.-Clear) can lead to confusing behavior.-UEcause the-Namemi-ilnamePredicates always return false.
Do not follow symbolic links except when processing command line arguments. Whenthinkbrowses or prints information about files, the information used must be obtained from the properties of the symbolic link itself. The only exception to this behavior is when a file specified on the command line is a symbolic link and the link can be resolved. For this situation, the information used is taken from the point the link points to (ie, the link is followed). The information about the link itself is used as a fallback if the file that the symlink points to cannot be browsed. Yeah-His active and one of the paths specified on the command line is a symbolic link to a directory, the contents of that directory are examined (although the maximum depth of 0 obviously prevents this).

If more than one of-H,-UEmi-PAGEis specified, each overwrites the others; The last one that appears on the command line takes effect. As is the default, the-PAGEThe option is considered ineffective unless-Ho-UEspecified.

FIELDthinkoften file statistics during processing from the command line itself, before starting a search. These options also affect how these arguments are processed. In particular, there are several tests that compare the files listed on the command line with a file we are currently considering. In each case, the file specified on the command line was examined and some of its properties were saved. If the named file is actually a symbolic link and the-PAGEoption is active (or if none-Hno-UEspecified), the information used for the comparison is taken from the properties of the symbolic link. Otherwise, it is removed from the properties of the file the link points to. Yeahthinkcannot follow the link (for example, because you do not have sufficient permissions or the link points to a file that does not exist), the properties of the link itself are used.

If he-Ho-L options are in effect, all symbolic links are listedas an argument from-lastthe reference is removed and the timestamp is removed from the file to which the symbolic link points. The same reasoning applies to-nuevoXY,- a young manmi-cneuer.

o-CrossThe option has a similar effect to-UE, although it takes effect the moment it appears (that is, when-UEalthough it is not used-Crossi.e. any symlinks that appear after it-Crossin the command line they are dereferenced and the previous ones are not).

-D debugging options
print diagnostic information; This can be helpful in diagnosing why the problemsthinkit doesn't do what you want. The list of debugging options must be separated by commas. Compatibility of debugging options between versions of findutils is not guaranteed. See the output of for a complete list of valid debugging options.find -DHelpValid debugging options include
Show diagnostic information about -exec, -execdir, -ok and -okdir
Explain debugging options.
Print diagnostic information for expression tree optimization; see -O option.
Prints a summary of the number of times each predicate succeeded or failed.
Navigate in detail through the directory tree.
Print messages when files are scanned withConditionmilstatsystem calls. thethinkThe program tries to minimize such calls.
See the expression tree in its original and optimized form.
- They are
Enable query optimization. thethinkthe program rearranges the tests to speed up execution while preserving the overall effect; That is, predicates with side effects do not reorder each other. The optimizations performed at each optimization level are as follows.
Corresponds to optimization level 1.
This is the default optimization level and corresponds to traditional behavior. The expressions are reordered so that the tests are based solely on the filenames (eg.-Namemi- Regex) are executed first.
neither- Arto- xtipoThe tests run after any tests that rely only on filenames, but before any tests that require inode information. In many modern versions of Unix, file types are returnedlearndir()Therefore, these predicates are faster to evaluate than predicates that have to initialize the file first. If you use the- kind ofFOOPredicate and specify a file system typeFOOwhich is currently unknown (ie, exists in `/etc/mtab').thinkbegins, this predicate is equivalent to-INCORRECT.
At this optimization level, the full cost based query optimizer is enabled. The order of the tests is changed so that the cheap (ie fast) tests are run first and the more expensive tests are run later, if necessary. Within each cost range, predicates will sooner or later be evaluated based on whether or not they are likely to succeed. To, predicates with probability of success are evaluated first and, for example,-a, the predicates that are likely to fail are evaluated first.
The cost-based optimizer has a fixed idea of ​​the probability of success of any test. In some cases, probability takes into account the specific nature of the test (eg.-Type fshould have a better chance of success than-Type c). The cost-based optimizer is evaluated. If it doesn't really improve the performance of thethink, it will be deleted again. On the other hand, settings that prove to be reliable, robust, and effective may be activated at lower setting levels over time. However, the default behavior (ie optimization level 1) will not change in the 4.3.x release series. The findutils test suite runs all teststhinkat each optimization level and ensures that the result is the same.


The part of the command line after the list of start points is theExpressionThis is a type of query specification that describes how we match files and what we do with the matching files. An expression is a sequence of things:

The tests return a true or false value, usually based on some property of a file we are considering. the-office hourFor example, the test is true only if the current file is empty.
Actions have side effects (such as printing something to stdout) and return true or false, usually based on success or failure. the-pressFor example, the action writes the name of the current file to standard output.
global options
Global options affect the operation of tests and actions specified anywhere on the command line. Global options always return true. the-Depthoption to do for examplethinktraverse the file system in order of depth.
positional options
Position options affect only the tests or actions that follow them. Position options always return true. the-regextypeFor example, the option is positional and specifies the regular expression dialect for regulatory expressions that appear later on the command line.
Operators connect the other elements within the expression. These include, for example(means logical OR) and-a(means logical AND). If an operator is missing,-ais assumed.

If the entire expression contains no action other than-Plumo-press,-pressruns on all files for which the entire expression is true.

o-ClearThe action also works as an option (since it implies-Depth).


Position options always return true. They only affect tests that are performed later on the command line.

- Start of the day
measurement times (eg.-amin,-one moment,-cmin,-ctime,-mm, z-mtime) from the beginning of today instead of 24 hours ago. This option only affects tests that then appear on the command line.
Disrupted; use the-UEoption instead. Dereference symbolic links.-no blade-CrossThe option only affects tests that appear later on the command line. unless he-Ho-UEoption was specified, the position of the-Crossoption changes the behavior of the-lastPredicate; all files listed as argument f-lastthey are dereferenced if they are symbolic links. The same reasoning applies to-nuevoXY,- a young manmi-cneuer.. In the same way that- ArtThe predicate always matches the type of file a symbolic link points to, not the link itself.-Crosscause the-name and-ilnamePredicates always return false.
Changes the regular expression syntax understood by- Regexmi-iregexTests that are run later on the command line. To see what types of regular expressions are known, use-regextypeHelp.The Texinfo documentation (seeI GET ITtuberculosis) explains the meaning and differences between the different types of regular expressions.
-advertir, -nowarn
Enable or disable alerts. These warnings apply only to command line usage, not to conditions thatthinkit can be found by searching directories. The default behavior is the same-to warnwhen standard input is a tty, and for-saberbesides. If there is a warning about using the command line, the exit status will bethinkIt is not affected. If the environment variable POSIXLY_CORRECT is set and-warn is used, it does not specify which warnings, if any, are active.


Global options always return true. Global options also take effect for tests previously run on the command line. To avoid confusion, global options should be specified on the command line after the start point list, just before the first test, position option, or action. If you specify a global option elsewhere,thinkprints a warning message explaining that this can be confusing.

Global options come after the starting point list and are therefore not the same option type as-UE,for example.

Synonymous with depth, with compatibility with FreeBSD, NetBSD, MacOS X and OpenBSD.
Process the content of each directory before the directory itself. The delete action also implies-Depth.
-Help help
Print a summary of command line usage fromthinky ve.
Principally,thinkprints an error message if a file cannot be started. If you specify this option, a file will be deleted in the meantimethinkreads the file name from the directory and tries not to print an error message when trying to find the file. This also applies to files or directories whose names are specified on the command line. This option takes effect as soon as the command line is read, which means that you will not be able to scan part of the file system when this option is on, and part of it when this option is off (if necessary, you must enter twothinkcommands, one with option and one without).
- Max deeplevels
go to the maxlevels(a non-negative integer) Directory levels below thresholds.- max depth 0
it simply means applying the tests and actions to the starting points themselves.
-min depthlevels
Do not apply patches or actions at levels belowlevels(a non-negative integer).-min depth 1means to process all files except starting points.
Do not remove directories on other file systems. An alternate name for-xdev, for compatibility with some other versions ofthink.
Turn off the effect-ignore_readdir_race.
-no blade
Don't optimize directories assuming they contain 2 fewer subdirectories than the number of your hard links. This option is required when searching for file systems that do not follow the Unix directory binding convention, such as . B. CD-ROM or MS-DOS file systems or AFS volume mount points. Every directory in a normal Unix file system has at least 2 hard links: its name and its '.' Forbidden. Also, its subdirectories (if any) have a '..' entry associated with that directory. Whenthinklooked at a directory and declared 2 subdirectories less than the directory's link count, it knows that the remaining entries in the directory are not directories ("leaf" files in the directory tree). If you only need to parse the filenames, you don't need to declare them; this leads to a significant increase in search speed.
-Version, -Version
press thethinkversion number and exit.
Do not remove directories on other file systems.


Some tests for example-nuevoXYmi- same file, allows comparison between the currently browsed file and a reference file specified on the command line. When these tests are used, the interpretation of the reference file is determined by the options-H,-UEmi-PAGEand all of the above-Cross, but the reference file is only examined once when parsing the command line. If the referenced file cannot be examined (for example, theCondition(2) for this the system call fails), an error message is issued andthinkexits with a non-zero status.

Numeric arguments can be specified as

For more thannorte,
for less thannorte,
for exactlynorte.
The file was last accessednorteA few minutes ago.
- a young manarchive
The file was last accessed asarchiveIt has been modified. Yeaharchiveis a symbolic link and the-Hoption or the-UEis enabled, the access time of the file it points to is always used.
-one momentnorte
The file was last accessednorte*24 hours ago. When finding how many 24-hour periods ago the file was last accessed, any fractions are ignored for a match-one moment+1, at least one file must have been accessedFromDays ago.
The file status was last modified.norteA few minutes ago.
File status was last changed asarchiveIt has been modified. Yeaharchiveis a symbolic link and the-Hoption or the-UEis enabled, the state change time of the file it points to is always used.
The file status was last modified.norte*24 hours ago See comments for-one momentunderstand how rounding affects the interpretation of file state modification times.
-office hour
The file is empty and is a normal file or directory.
Matches files that are executables and directories that are searchable (in the sense of file name resolution). This takes into account ACLs and other permission artifacts that the-Permanenteignore test. They are tests of use oraccess(2) System call and thus can be fooled by NFS servers doing UID mapping (or root squashing) as many systems implementaccess(2) In the client's kernel and therefore cannot use the UID mapping information stored on the server. Because this test is only based on the result of theaccess(2) System call, there is no guarantee that a file that passes this test can actually be executed.
Always wrong
- kind ofuntil
The file resides on a file system of typeuntil. The valid file system types vary between different versions of Unix; A partial list of file system types supported by one version of Unix or another is: ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K. You can use-printfwith the %F directive to display the types of your file systems.
The numeric group ID of the file isnorte.
The file belongs to the group.Name(Allowed Numeric Group ID).
In focus-Name, but the match is not case sensitive. If he-UEoption or the-Crossis active, this test returns false unless the symlink is broken.
- Foamstandardize
In focus-Name, but the match is not case sensitive. For example, the patterns `fo*' and `F??' matches filenames `Foo', `FOO', `foo', `fOo', etc. The pattern "*foo*" also matches a file called ".foobar".
they have been drinkingnorte
The file has an inode numbernorte. It's usually easier to use those- same filetry instead.
In focus-Outside.but the comparison is not case sensitive.
In focus- Regex, but the match is not case sensitive.
-iFull namestandardize
See -ipath. This alternative is less portable than-iPfad.
the file hasnorteconnections.
The file is a symbolic link whose content matches the shell patternstandardize. Metacharacters do not handle `/' or `. particularly. If he-UEoption or the-Crossis active, this test returns false unless the symlink is broken.
File dates were last modifiednorteA few minutes ago.
File dates were last modifiednorte*24 hours ago See comments for-one momentUnderstand how rounding affects the interpretation of file modification times.
The file name base (the path with the root directories removed) conforms to the shell patternstandardize. Since the root directories have been removed, the file names are taken into account for a match-Namewill never contain a slash, so `-name a/b' will never match anything (you'll probably need to use-Outsideinstead of). Attempting to do this will result in a warning unless the POSIXLY_CORRECT environment variable is set. Metacharacters (`*', `?' and `[]') match a `.' at the beginning of the base name (this is a change in findutils-4.2.2; see the STANDARDS COMPLIANCE section below). To ignore a directory and the underlying files, use-Plum; see an example in the description of-OutsideParentheses are not recognized as special, although some shells, including bash, give special meaning to parentheses in shell standards. File name comparison is done with thefn party(3) library function. Don't forget to enclose the pattern in quotes to protect it from shell expansion.
The file was recently modified asarchive. Searchiveis a symbolic link and the-Hoption or the-UEis enabled, the modification time of the file it points to is always used.
Success if timestampXof the file viewed is newer than the timestampYthe filerealize. LettersXmiYcan be one of the following letters:
afile access timerealize
BThe birth time of the file.realize
CThe inode state change time fromrealize
metroThe file modification time.realize
trealizeis interpreted directly as time

Some combinations are not valid; For example, it is not valid forXbe yourst.Some combinations are not implemented on all systems; for exampleBit is not compatible with all systems. If an invalid or unsupported combination ofXYspecified, a fatal error occurs. Times are interpreted in the same way as for the argument.-dGNU optionmeeting.If you try to use the birth time from a reference file and the birth time cannot be determined, a fatal error message is displayed. If you specify a test that references the creation time of the examined files, this test will fail for all files for which the creation time is unknown.

-no group
No groups match the file's numeric group ID.
No user matches the file's numeric user ID.
Filename matches shell patternstandardize. Metacharacters do not handle `/' or `. particularly; for example
distance -Route "./sr*sc"
prints an entry for a directory named `./src/misc' (if it exists). To skip an entire directory tree, use-Pluminstead of checking each file in the tree. For example, to skip the `src/emacs' directory and all files and directories under it and print the names of other files found, do the following:
find -ruta ./src/emacs -prune -o -print
Note that the pattern matching test applies to the entire file name, starting at one of the named start points on the command line. It would only make sense to use an absolute pathname here if the relevant starting point is also an absolute path. That means this command will never match anything:
find bar -ruta /foo/bar/myfile -print
compare those-OutsideAn argument that concatenates a directory name and the base name of the file you are examining. Since concatenation never ends with a slash,-OutsideArguments ending in a slash do not match anything (except perhaps a starting point specified on the command line). the predicate-Outsidealso supports HP-UXthinkand will be included in a future version of the POSIX standard.
File permission bits are accurateOutside(octal or symbolic). Because an exact match is required, you may need to supply a rather complex mode string if you want to use this form for symbolic modes. For example, '-perm g=w' will only search for files that have mode 0020 (ie those for which group write permission is the only permission). You will most likely want to use the '/' or '-' forms, eg '-perm -g=w', which matches any file with group write permissions. Watch theEXAMPLESsection for some illustrative examples.
All permission bitsOutsideare defined for the file. Symbolic modes are supported in this format, and this is generally how you want to use them. You must specify 'u', 'g', or 'o' when using symbolic mode. Watch theEXAMPLESsection for some illustrative examples.
-permanente /Outside
All permission bitsOutsideare defined for the file. Symbolic modes are accepted in this form. You must specify 'u', 'g', or 'o' when using symbolic mode. Watch theEXAMPLESsection for some illustrative examples. If there are no authorization bits in itOutsideare defined, this test will match any file (the idea here is to be consistent with the behavior of-Permanente-000).
-duration +Outside
This is no longer supported (and has been deprecated since 2005). Use-permanente /Outsideinstead of.
Matches files that are readable. This accounts for ACLs and other permission artifacts that the-Permanenteignore test. They are tests of use oraccess(2) System call and thus can be fooled by NFS servers doing UID mapping (or root squashing) as many systems implementaccess(2) In the client's kernel and therefore cannot use the UID mapping information stored on the server.
- Regexstandardize
Filename matches regular expressionstandardize. This is a complete match, not a search. For example, to match a file named "./fubar3", you can use the regular expression ".*bar". or `.*b.*3', but not `f.*r3'. Regular expressions are understood bythinkare Emacs regular expressions by default, but this can be changed with-regextypePossibility.
- same fileName
The file points to the same inode asName. When-UEis effective, this can include symlinks.
file usednorteSpatial units, rounded up. The following suffixes can be used:
for 512-byte blocks (this is the default if no suffix is ​​used)
professional bytes
for two-byte words
in kilobytes (units of 1024 bytes)
in megabytes (units of 1048576 bytes)
in gigabytes (units of 1073741824 bytes)
The size does not count indirect blocks, but it does count blocks in sparse files that are not actually allocated. Remember that the '%k' and '%b' format specifiers are used by-printfHandle sparse files differently. The `b' suffix always denotes 512-byte blocks and never 1-kilobyte blocks, which differs from the behavior of-ls.
The prefixes + and - mean greater than and less than, as usual. Remember that the size is rounded to the nearest unit. Therefore-Size -1Mis not synonymous with-Size -1048576c.The former only matches empty files, the latter matches files from 1 to 1,048,575 bytes.
Always true.
- ArtC
The file is of typeC:
special block (buffered)
Special characters (unbuffered).
named pipe (FIFO)
normal dates
symbolic link; that is never true when the-UEoption or the-CrossThe option is effective unless the symbolic link is broken. If you want to search symbolic links when-UEis in effect, use- xtipo.
Portal (Solaris)
To search for more than one type at a time, you can provide the combined list of type letters separated by a comma `,' (GNU extension).
The numeric user ID of the file isnorte.
The file was last accessednorteDays since the last time your status was changed.
-of the userNameless
The file is owned by the user.Nameless(Allowed Numeric User ID).
-Full namestandardize
See route. This alternative is less portable than-Outside.
Matches the writable files. This accounts for ACLs and other permission artifacts that the-Permanenteignore test. They are tests of use oraccess(2) System call and thus can be fooled by NFS servers doing UID mapping (or root squashing) as many systems implementaccess(2) In the client's kernel and therefore cannot use the UID mapping information stored on the server.
- xtipoC
The same as- Artunless the file is a symbolic link. For symbolic links: if the-Ho-PAGEThe option is true if the file is a link to a file of typeC; yes or-UEOption specified, true ifCand me'. In other words, for symbolic links,- xtipoCheck file type- Artdoes not check.
(SELinux only) File security context matches globstandardize.


Delete files; true if the removal is successful. If the removal fails, an error message is issued. Yeah-ClearError,think'The exit status will be different from zero (in case of eventual exit).-Clearturn on automatically-Depth'Possibility.

SuggestionsNote: Don't forget that the search command line evaluates to an expression, so put-ClearI will do it firstthinkTry to remove everything below the specified thresholds. When trying athinkCommand line you want to use later-Clear, you must specify it explicitly-Depthto avoid surprises later. why-Clearthat means-Depth, cannot be used sensibly-Plummi-Cleartogether.

Rundomain; true if status 0 is returned. All of the following arguments in favor ofthinkare considered command arguments until one argument consists of ';' it's found. The string "{}" is replaced with the name of the file currently being processed wherever it appears in command arguments, not just arguments where it stands alone, as in some versions ofthink.Both constructs may need to be escaped (with a `\') or quoted to protect them from shell expansion. Watch theEXAMPLESUsage Examples Section-executivePossibility. The specified command is executed once for each matching file. The command is executed in the home directory. There are unavoidable security issues when using-executiveAction; you have to use those-ejectoroption instead.
-executivedomain{} +
This variant of-executivethe action runs the specified command on the selected files, but the command line is created by appending each selected filename to the end; The total number of command calls is much less than the number of corresponding files. The command line is structured the same asxargscreate your command lines. Only one instance of `{}' is allowed within the command. The command is executed in the home directory. If any call returns a non-zero exit status, thenthinkreturns a non-zero exit status. Yeahthinkfinding an error can sometimes result in an immediate exit, so some pending commands may not be executed. This variant of-executivealways returns true.
-ejectordomain{} +
In focus-executive, but the specified command is executed from the subdirectory containing the appropriate file, which is usually not the directory it started fromthink.This is a much safer method of invoking commands, as it avoids race conditions when resolving paths to matching files.-executiveAction, the '+' form of-ejectorcreates a command line to process more than one matching file, but each call todomainit just lists the files that exist in the same subdirectory. If you use this option, you must ensure that your$RUTAThe environment variable does not refer to `.'; Otherwise, an attacker could execute any command and leave an appropriately named file in a directory where he will execute it.-ejector.The same applies to entries in$RUTAwhich are empty or are not absolute directory names. If any call returns a non-zero exit status, thenthinkreturns a non-zero exit status. Yeahthinkfinding an error can sometimes result in an immediate exit, so some pending commands may not be executed. The result of the action depends on whether the+or the;the variant is used;-ejectordomain{} +always returns true while-ejectordomain{} ;returns true only ifdomainreturns 0.
TRUE; What-lsbut write toarchiveIn focus-fprint.The output file is always created even if the predicate never matches. Watch theUNUSUAL FILE NAMESSection for information on handling unusual characters in file names.
TRUE; Print the full file name in the filearchive. Searchivedoes not exist whenthinkit is running, it is being created; If it is present, it will be truncated. The filenames `/dev/stdout' and `/dev/stderr' are treated special; refer to the standard output and standard error, respectively. The output file is always created even if the predicate never matches. Watch theUNUSUAL FILE NAMESSection for information on handling unusual characters in file names.
TRUE; What-print0but write toarchiveIn focus-fprint.The output file is always created even if the predicate never matches.UNUSUAL FILE NAMESSection for information on handling unusual characters in file names.
-fprintfarchive Format
TRUE; What-printfbut write toarchiveIn focus-fprint.The output file is always created even if the predicate never matches.UNUSUAL FILE NAMESSection for information on handling unusual characters in file names.
TRUE; list the current file inls-dilsformat on stdout. Block counts are 1K blocks unless the POSIXLY_CORRECT environment variable is set, in which case 512-byte blocks are used. Watch theUNUSUAL FILE NAMESSection for information on handling unusual characters in file names.
In focus-executivebut ask the user first. If the user agrees, run the command. Otherwise, just return false. When the command is executed, its standard input is redirected using/dev/null.
The response to the prompt is compared to a pair of regular expressions to determine if the response is positive or negative. This regular expression is retrieved from the system if the 'POSIXLY_CORRECT' environment variable is set, or otherwisethink'News translations. If the system does not have a proper configuration,think'The initial definition is used. In both cases, the interpretation of the regular expression itself is affected by the environment variables 'LC_CTYPE' (character classes) and 'LC_COLLATE' (character range and equivalence classes).
- it's okaydomain;
In focus-ejectorbut ask the user first in the same way as for-OK.If the user doesn't agree, just return false. When the command is executed, its standard input is redirected using/dev/null.
TRUE; prints the full filename to standard output, followed by a new line. If you direct the exit ofthinkin another program, and there's even the slightest chance that the files you're looking for might contain a newline, then you should seriously consider using that-print0option instead-press.Watch theUNUSUAL FILE NAMESSection for information on handling unusual characters in file names.
TRUE; prints the full filename to standard output, followed by a null character (instead of the newline character that-pressUse). This allows programs that process the file to correctly interpret file names that contain newlines or other types of spaces.thinkDeparture. This option corresponds to-0option ofxargs.
TRUE; FastFormaton standard output, interpret the `\'escapes and `%' directives. Field widths and precisions can be specified with the C function `printf'. Note that many of the fields are printed as %s instead of %d and this could mean that the flags are not working as expected. It also means that the `-' flag works (forces fields to be left-aligned). Different-press,-printfIt does not add a new line to the end of the string. The escape characters and directives are:
Immediately stop printing from this format and discard the output.
Food form.
new line.
Return by carriage.
Landscape orientation.
From verticals.
A literal backslash (`\').
The character whose ASCII code is NNN (octal).

A `\' character followed by another character is treated as a normal character, so both are printed.

A literal percent sign.
The time of the last access to the file, in the format returned by the C function `ctime'.
The last access time of the file in the specified formatk, which is either `@' or a directive to the C function `strftime'. The possible values ​​ofkThey are listed below; some of them may not be available on all systems due to differences in `strftime' between systems.
Seconds since January 1, 1970 00:00 GMT, with fractions.

time fields:

Time (00..23)
Time (01..12)
Time (0..23)
time (1..12)
minutes (00..59)
AM or PM of the location
Time, 12 hours (hh:mm:ss [AP]M)
second (00.00 .. 61.00). There is a fraction.
hour, 24 hours (hh:mm:ss.xxxxxxxxxx)
Date and time separated by "+", for example "2004-04-28+22:22:05.0". This is a GNU extension. The time is given in the current time zone (which can be affected by setting the TZ environment variable). The seconds field contains a fraction.
Temporal representation of the locality (H:M:S). The seconds field contains a fraction.
Time zone (for example, EDT) or nothing if no time zone can be determined

Date fields:

abbreviated name of the local day of the week (Sun..Sat)
Full name of the locale day of the week, variable length (Sunday...Saturday)
Abbreviated local month name (Jan..Dec.)
full month place name, variable length (January...December)
Local date and time (Saturday, November 4, 12:02:33 PM EST 1989). The format is the same as forctime(3) To maintain compatibility with this format, there is no fraction in the seconds field.
Day of the month (01..31)
Fecha (dd/mm/aa)
the same as b
Day of the year (001..366)
Mes (01..12)
Week number of the year with Sunday as the first day of the week (00..53)
Day of the week (0..6)
Week number of the year with Monday as the first day of the week (00..53)
Local date representation (MM/DD/YY)
the last two digits of the year (00..99)
again (1970...)
The space used for this file in blocks of 512 bytes. Because space is allocated in multiples of the file system block size, it is typically larger than %s/512, but may be smaller if the file is sparse.
Time of the last state change of the file in the format returned by the C function `ctime'.
Time of the last state change of the file in the specified formatk, which is the same as for %A.
depth of the file in the directory tree; 0 means the file is a starting point.
The device number on which the file exists (the st_dev field of structstat), in decimal.
Filename with all root directories removed (only the last item).
type of file system on which the file resides; this value can be used for -fstype.
% grams
File group name or numeric group ID if the group has no name.
Numeric group ID of the file.
% h
File name parent directories (all but the last item). If the filename does not contain slashes (since it is in the current directory), the %h specifier expands to ".".
Starting point where the file was found.
File inode number (decimal).
The space used for this file in 1K blocks. Since space is allocated in multiples of the file system block size, it is typically greater than %s/1024, but may be less if the file is sparse.
Symbolic link object (empty string if the file is not a symbolic link).
File permission bits (in octal). This option uses the "traditional" numbers used by most Unix implementations, but if your particular implementation uses an unusual octal permission bit order, you will see a difference between the actual value of the file mode and the output of %m . Normally you want this number to have a leading zero, and that's what you would use#Indicator (as in `%#m').
File permissions (in symbolic form, such asls). This directive is supported in findutils 4.2.5 and later.
Number of hard links to the file.
file name.
Removed the file name with the name of the starting point where it was found.
File size in bytes.
sparse file. This is calculated as (BLOCKSIZE*st_blocks /st_size). The exact value you get for a typical file of a given size depends on the system. However, sparse files typically have values ​​less than 1.0, and files that use indirect blocks can have values ​​greater than 1.0. The value used for BLOCKSIZE is system dependent, but is typically 512 bytes. If the file size is zero, the printed value is undefined. On systems that do not support st_blocks, the spread of a file is assumed to be 1.0.
The time the file was last modified in the format returned by the C function `ctime'.
Time the file was last modified in the specified formatk, which is the same as for %A.
File username or numeric user ID if the user does not have a name.
Numeric user ID of the file.
file type (as inls-l),U=unknown type (must not occur)
File type (eg %y) plus the following symlinks: L=loop, N=none
(SELinux only) The security context of the file.
%{ %[ %(
Reserved for future use.

A '%' character followed by another character will be discarded, but the other character will be printed (do not rely on this as other formatting characters may be introduced). A '%' at the end of the format argument causes undefined behavior as there are no subsequent characters. In some places it can hide the door keys, while in others it can remove the last page of the novel you are reading.

The %m and %d directives support the#,0mi+flags, but the other directives don't, although they do print numbers. Include numeric directives that do not support these flagsGRAMS,ella,b,D,kminorteThe `-' format flag is supported and changes the alignment of a field from right justified (default) to left justified.

Watch theUNUSUAL FILE NAMESSection for information on handling unusual characters in file names.

TRUE; If the file is a directory, don't go there. Yeah-Depthit is given, false; without effect. why-Clearthat means-Depth, cannot be used sensibly-Plummi-Cleartogether.
go immediately No child processes are executed, but other paths specified on the command line are not processed. For example,encuentra /tmp/foo /tmp/bar -print -quitit is only printed/tmp/foo.All command lines built with-ejec ... {} +called beforethinkexits The exit status may or may not be null depending on whether an error has already occurred.


Listed in descending order:

enforce priority. Since parentheses are special to the shell, you should generally enclose them in quotes. Many of the examples in this manual page use backslashes for this purpose: `\(...\)' instead of `(...)'.
true yesExpressionis false This character should also generally be escaped from shell interpretation.
same !Expression, but not POSIX compliant.
expression1 expression2
Two consecutive terms are joined with an implied "and";expression2will not be evaluated ifexpression1it's false
sameexpression1 expression2.
sameexpression1 expression2, but not POSIX compliant.
O;expression2will not be evaluated ifexpression1It's true.
sameexpression1expression2, but not POSIX compliant.
Ready; Bothexpression1miexpression2are always evaluated. The value ofexpression1discarded; The list value is the value ofexpression2. The comma operator can be useful for looking up many different things, but only for traversing the file system hierarchy once. the-fprintfThe action can be used to list multiple matching items in multiple different output files.

Realise-awhether it is specified implicitly (for example, by two tests appearing without an explicit operator between them) or explicitly has a higher precedence than.This means thatthink . -filename -o -filename b -printwill never printconvey a message.


Many of the actionsthinkresult in the printing of data controlled by other users. This includes file names, sizes, modification times, etc. Filenames are a potential problem as they can contain any characters except `\0' and `/'. Unusual characters in filenames can do unexpected and often undesirable things to your terminal (for example, change function key settings on some terminals). Unusual characters are treated differently by different actions, as described below.

-print0, -printprint0
Always send the exact filename without changes, even when sending to a terminal.
-ls, -fls
Unusual characters are always masked. Whitespace, backslash, and double quotes are printed with C-style escape characters (for example, `\f', `\"'). Other unusual characters are printed with octal escape characters. Other printable characters (for example,-lsmi-flsthese are the characters between octal 041 and 0176) are printed without change.
-printf, -fprintf
If the output does not go to a terminal, it is printed as-is. Otherwise, the result depends on which directive is used. The %D, %F, %g, %G, %H, %Y, and %y directives are expanded to values ​​that are not under the control of the file's owners and are therefore printed as-is. The %a, %b, %c, %d, %i, %k, %m, %M, %n, %s, %t, %u, and %U directives have values ​​that are controlled by the file owner, but that they cannot be used to send any data to the terminal and are therefore printed unchanged. The directives %f, %h, %l, %p and %P are referenced. This quote works the same as for GNUls.This is not the same citation mechanism used to-lsmi-fls.If you can decide which format to use for the outputthinkTherefore, it is usually better to use `\0' as a terminator than to use new lines, since file names can contain spaces and new line characters. The setting of the 'LC_CTYPE' environment variable is used to determine which characters should be quoted.
-print, -print
The quote is treated as if it were-printfmi-fprintf.and usethinkin a script or in a situation where matching files may have arbitrary names, consider using-print0instead of-press.

o-OKmi- it's okayThe actions output the current file name unchanged. This may change in a future version.


For further compliance with the POSIX standard, you should set the POSIXLY_CORRECT environment variable. The following options are specified in the POSIX standard (IEEE Std 1003.1, 2003 Edition):

This option is supported.
This option is supported.
This option is supported, but POSIX compliance depends on the POSIX compliance of the systemfn party(3) library function. As of findutils-4.2.2, shell metacharacters (for example, "*", "?", or "[]") match a ".". initially because the interpretation of IEEE PASC 126 requires it. This is a change from previous versions of findutils.
- Art
supports. POSIX specifies 'b', 'c', 'd', 'l', 'p', 'f', and 's'. GNU find also supports 'D', which is a port where the operating system provides them. Furthermore, GNU find allows you to specify multiple types at once in a comma-separated list.
supports. The response is interpreted according to the "yes" and "no" patterns selected by setting the `LC_MESSAGES' environment variable. negative answer (no). Consult your system documentation fornl_langinfo(3), in particular YESEXPR and NOEXPR. If `POSIXLY_CORRECT' is not defined, default values ​​are usedthink'Catalogue of Planted News.
supports. If the specified file is a symbolic link, the reference is always removed. This is a change from previous behavior where the relevant tense was removed from the symlink; see the HISTORY section below.
supports. If the POSIXLY_CORRECT environment variable is not set, some mode arguments (eg, +a+x) that are invalid in POSIX are supported for backwards compatibility.
other predicates
the predicates-one moment,-ctime,-Depth,-Group,-Links,-mtime,-no group,-nouser,-press,-Plum,-Size,-of the usermi-xdev'-atime', '-ctime', '-profundidad', '-group', '-links', '-mtime', '-nogroup', '-nouser', '-perm', '-print', Se admiten `-prune', `-size', `-user' y `-xdev'.

The POSIX standard specifies square brackets `(', `)', negation `!' and the 'and' and 'or' operators (-a,).

All other options, predicates, expressions, etc. they are extensions beyond the POSIX standard. However, many of these extensions are not unique to GNU find.

The POSIX standard requires thisthinkDetecta-Schleifen:

othinkThe utility must detect infinite loops; that is, enter a previously visited directory that is an ancestor of the last file found. If it encounters an infinite loop, find should write a diagnostic message to standard error and restore or exit its position in the hierarchy.

FIELDthinkMeets these requirements. The link count for directories containing entries that are hard links to an ancestor will generally be lower than it should be. This can mean that GNU find sometimes optimizes visiting a subdirectory that is actually a link to an ancestor. Given thatthinkdoes not actually go into that subdirectory, it is permissible to avoid output of a diagnostic message. Although this behavior can be somewhat confusing, it is unlikely that anyone would actually trust this behavior. If sheet optimization was disabled with-no bladeThe phone book entry is always examined and, if necessary, the diagnostic message is issued. Symbolic links cannot be used to create file system loops as such, but if the-UEoption or the-Crossoption is used, a diagnostic message is issued ifthinkfinds a loop of symbolic links. As with loops containing hard links, leaf optimization usually means thisthinkYou know you don't have to callCondition()ochdir()in the symbolic link, so this diagnosis is often not necessary.

o-dThe option is compatible with many BSD systems, but you must use the POSIX-compatible option-Depthinstead of.

The POSIXLY_CORRECT environment variable does not affect the behavior of the- Regexo-iregexbecause these tests are not specified in the POSIX standard.


Provides a default value for internationalization variables that are undefined or null.
If set to a non-empty string value, substitute the values ​​of all other internationalization variables.
The POSIX standard states that this variable affects the pattern matching to be used for the-NamePossibility. GNU find uses thefn party(3) The library function and therefore the support for 'LC_COLLATE' depends on the system library. This variable also influences the interpretation of the response.-OK;while the 'LC_MESSAGES' variable selects the actual pattern used to interpret the response-OK, the interpretation of all parentheses in the pattern will be affected by `LC_COLLATE'.
This variable affects the handling of character classes used in and also with regular expressions.-NameTest if the systemfn party(3) The library function supports this. This variable also affects the interpretation of all character classes in the regular expressions used to interpret the quick response from-OK.The 'LC_CTYPE' environment variable also affects which characters are considered non-printable when printing filenames; see the UNUSUAL FILE NAMES section.
Determines the locale to be used for internationalized messages. If the environment variable 'POSIXLY_CORRECT' is set, this also determines the interpretation of the response to the request.-OKAction.
Determines the location of the internationalization message catalogs.
Affects which directories are searched to find executables that have been invoked-executive,-ejector,-OKmi- it's okay.
Determines the block size used from-lsmi-fls.SePOSIXLY_CORRECTis defined, blocks are units of 512 bytes. Otherwise, they are 1024-byte units.
Setting this variable also disables warning messages (that is, it implies-saber) by default because POSIX requires this in addition to output for-OK, all messages printed to stderr are diagnostic and should generate a non-zero exit status.
If POSIXLY_CORRECT is not set,-Permanente+zzzis is treated as-Permanente/zzzif+zzz is not a valid symbolic mode. If POSIXLY_CORRECT is set, such constructs are treated as errors.
If POSIXLY_CORRECT is set, the response to the request is replaced by the-OKThe action is interpreted based on the system message catalog, rather than based onthink'Translations of seeded messages.
It affects the time zone used for some of the time-related format declarations.-printfmi-fprintf.


find /tmp -kernel name -type f -print | xargs /bin/rm -f

Find named filessignificantinside or below the directory/tmpand delete them. Note that this will not work correctly if the file names contain new lines, single or double quotes, or spaces.

find /tmp -kernel name -type f -print0 | xargs -0 /bin/rm -f

Find named filessignificantinside or below the directory/tmpand delete, processing filenames in a way that correctly handles filenames or directories that contain single or double quotes, spaces, or newlines. the-Namethe test comes before- Arttry to avoid a callCondition(2)in each file.

think . -type f -exec file '{}' \;

Runs 'file' on all files in or below the current directory. Note that the braces are enclosed in single quotes to prevent them from being interpreted as shell script punctuation. The semicolon is also escaped with a backslash, although single quotes can also be used in this case.

encontrar / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \\( -tamaño +100M -fprintf /root/big.txt '%-10s %p\n' \)

Traverse the filesystem only once, listing the setuid files and directories on it/root/suid.txtand large files in/root/grande.txt.

find $HOME -mtime 0

Look in your home directory for files that have been modified in the last 24 hours. This command works like this because the time since each file was last modified is divided by 24 hours and the rest is discarded. This means it fits-mtime0, a file must have been modified less than 24 hours ago.

find /sbin /usr/sbin -executable \! -readable -print

Look for executable but unreadable files.

sugar. - Permanent 664

Look for files that have read and write permissions for their owner and group, but that other users can read but not write. Files that meet these criteria but have other permission bits set (for example, if someone can execute the file) will not be compared.

pensar. -Duration-664

Look for files that have read and write permissions for their owner and group and that other users can read, regardless of whether there are additional permission bits (such as the executable bit). For example, this corresponds to a file with mode 0777.

pensar. -Duration /222

Search for files that can be written to by anyone (their owner, their group, or someone else).

pensar. -Duration /220achar -permanente /u+w,g+wachar -perm /u=w,g=w

These three commands do the same thing, but the first one uses the octal representation of file mode and the other two use the symbolic form. All of these commands look for files that their owner or group can write to. The owner and group do not need to be able to write to the files for them to match; everyone will.

pensar. -duration -220achar -permanente -g+w,u+w

Both commands do the same thing; Look for files that their owner and group can write to.

find -duration -444 -duration /222 ! -Duration /111achar -dauer -a+r -dauer /a+w ! -perm /a+x

These two commands look for files that are human readable (-duration -444o-permanente -a+r), have at least one set of write bits (-Duration /222o-permanente /a+w), but they are not executable for anyone (! -Duration /111mi! -perm /a+xo).

cd /source-directoryachar -name .snapshot -prune -o \( \! -name *~ -print0 \)|cpio -pmd0 /destination-dir

This command copies the content of/source-directoryPro/dir-destination, but omits named files and directories.Snapshot(and everything in them). It also skips files or directories whose name ends with~, but not its content. the construction-prune -o \( ... -print0 \)is quite common. The idea here is that the expression beforehand-Plumcorresponds to things that need pruning. However the-Plumthe action itself returns true, so the followingensures that the right hand side is only evaluated for non-remote directories (the content of remote directories is not even visited, so the content is irrelevant). The print on the right side of theit is in parentheses for clarity only. emphasizes that the-print0The action only happens for things that didn't have-Plumapplied to them. By default, 'e' is stronger than between tests, which is the default anyway, but the parentheses help show what's going on.

gegen repo/\( -exec test -d{}/.svn\;-or\-exec test -d {}/.git \; -ou -exec test -d {}/CVS \; \) \-print -crop

Perform an efficient search for the project roots using the following project directory and associated SCM admin directories:


In this example-Plumprevents unnecessary descents to already discovered directories (for example, we don't look for project3/src because we already found project3/.svn), but ensures that sibling directories (project2 and project3) are found.

against /tmp -type f,d,l

Find files, directories, and symbolic links in the directory/tmpPassing these types as a comma-separated list (GNU extension), which corresponds to the longest but most portable:

find /tmp \( -type f -o -type d -o -type l \)


thinkends with status 0 if all files were processed successfully, greater than 0 if errors occur. This is intentionally too broad a description, but if the return value is non-zero, you should not rely on the accuracy of the results ofthink.

If an error occurs,thinkit can be stopped immediately without taking any specific action. For example, some starting points may not have been examined yet, or some pending program calls to do so-executive... {} +o-ejec ... {} +it may not run.


As of findutils-4.2.2, shell metacharacters (such as "*", "?", or "[]") used in filename patterns match ".". initial because the interpretation of IEEE POSIX 126 requires it.

Ab findutils-4.3.3,-Duration /000now matches all files instead of none.

Nanosecond resolution timestamps have been implemented in findutils-4.3.3.

As of findutils-4.3.11, the-ClearAction setsthink'Set exit status to non-zero on failure.thinkit will not come out immediately. Until now,think'Gender status was not affected by the interruption-Clear.

special featureAggregateit also happens
-execute... +4.2.12Posix
- it's okay4.2.12
- same file4.2.11
-Full name4.2.0
-iFull name4.2.0
- Foam3.8

The .B -perm +MODE syntax was removed in findutils-4.5.12 in favor of .B -perm/OUTSIDE+MODEThe syntax is deprecated since findutils-4.2.21 was released in 2005.


Surprised Operator Priority

The commandthink . -filename -o -filename b -printwill never printconvey a messagebecause that really is equivalent toachar -name a file -o \( -filename -a -print \).Remember that the precedence of-aIs superiorand if no operator is specified between the tests,-ais assumed.

Error message "Paths must precede expression."

$find. -name *.c -printfind: paths must precede expression Usage: find [-H] [-L] [-P] [-Olevel] [-D ... [path...] [expression]

This happens because*.Cwas spread by the wrapper, leading tothinkactually always a command line like this:

achar -name frcode.c locate.c word_io.c -print

This command obviously doesn't work. Instead of doing things this way, consider enclosing the pattern in quotes or escaping the wildcard:

$find. -name '*.c' -print$find. -name \*.c -print


The behavior for which you specify the POSIX standard is associated with security issuesthink, which therefore cannot be fixed. For example, him-executiveThe action is intrinsically uncertain, and-ejectorshould be used instead. Watchfind filesFor more information.

environment variableLC_COLLATEhas no influence on-OKAction.

The best way to report a bug is to use the form below reason for this is so that you can track the progress of the troubleshooting. Other comments aboutthink(1) and through the findutils package, it can generally be sent to thebug-findutilsmailing list. To join the list, send an email to[email protected].


What command would I use to search for files in a directory hierarchy? ›

You can use the find command to search for a file or directory on your file system. By using the -exec flag ( find -exec ), matches, which can be files, directories, symbolic links, system devices, etc., can be found and immediately processed within the same command.

How do I get a list of files in a specific directory? ›

  1. To list all files in the current directory, type the following: ls -a This lists all files, including. dot (.) ...
  2. To display detailed information, type the following: ls -l chap1 .profile. ...
  3. To display detailed information about a directory, type the following: ls -d -l .

How do I search inside files in a directory? ›

To search for files in File Explorer, open File Explorer and use the search box to the right of the address bar. Tap or click to open File Explorer. Search looks in all folders and subfolders within the library or folder you're viewing. When you tap or click inside the search box, the Search Tools tab appears.

Where are the files of a given user stored in a typical file structure hierarchy of a Linux OS? ›

It is maintained by the Linux Foundation. In the FHS, all files and directories appear under the root directory /, even if they are stored on different physical or virtual devices.

What is the hierarchical collection of directories and files? ›

A hierarchical file system is how drives, folders, files, and other storage devices are organized and displayed on an operating system. In a hierarchical file system, the drives, folders, and files are displayed in groups, which allows the user to see only the files they're interested in seeing.

Which Linux command shows a list of files in a directory? ›

  • To list all files in the current directory, type the following: ls -a This lists all files, including. dot (.) ...
  • To display detailed information, type the following: ls -l chap1 .profile. ...
  • To display detailed information about a directory, type the following: ls -d -l .

How do I get a list of files in a folder and subfolders with path? ›

  1. Open File Explorer in Windows. ...
  2. Click in the address bar and replace the file path by typing cmd then press Enter.
  3. This should open a black and white command prompt displaying the above file path.
  4. Type dir /A:D. ...
  5. There should now be a new text file called FolderList in the above directory.

How can I get a list of all the subfolders and files present in a directory using PHP? ›

PHP using scandir() to find folders in a directory

The scandir function is an inbuilt function that returns an array of files and directories of a specific directory. It lists the files and directories present inside the path specified by the user.

How do I get a list of file names from a folder and subfolders? ›

Get a List of File Names from Folders & Sub-folders
  1. Go to the Data tab.
  2. In the Get & Transform group, click on New Query.
  3. Hover the cursor on the 'From File' option and click on 'From Folder'.
  4. In the Folder dialog box, enter the folder path, or use the browse button to locate it.
  5. Click OK.

How do I search inside multiple files? ›

To make the necessary settings to search in the text of the files, follow these steps:
  1. Open the folder you want to search in File Explorer, select the View menu and click the Options button.
  2. In the window that opens, click on the Search tab, select "Always search file names and contents" and click "OK"
Jan 28, 2021

What is the Unix command to find a file in a directory and subdirectory? ›

The grep command searches through the file, looking for matches to the pattern specified. To use it type grep , then the pattern we're searching for and finally the name of the file (or files) we're searching in.

Can you search without indexing? ›

You'll still be able to search by file name—just not file contents. Choosing not to index the contents of files can reduce the size of the index, but it makes files harder to find in some cases.

How to check file system hierarchy in Linux? ›

If you want to find out information about your system's FHS, enter the command man hier. It will display directory structure of your system.

How data is stored in a hierarchy? ›

A hierarchical database is a data model in which data is stored in the form of records and organized into a tree-like structure, or parent-child structure, in which one parent node can have many child nodes connected through links.

Which of the following command display the hierarchy of files and folders? ›

The pwd command (print working directory) displays where you are in the file system hierarchy.

How do I export a directory hierarchy? ›

To export the folder's structure, run this command: tree /a /f > output. doc. TIP: If you don't want the directory tree to include files (in other words, make the tree include only folders), skip the /f parameter from the command (tree /a > output.

What is hierarchical structure of a file system? ›

In the hierarchical file structure, records are arranged in a scheme resembling a family tree, with records related to one another from top to bottom. In the network file structure, records are arranged in groupings known as sets; these can be connected in any number of ways,…

How to find a file in Linux in all directories recursively? ›

How to get a recursive directory listing in Linux or Unix
  1. ls -R : Use the ls command to get recursive directory listing on Linux.
  2. find /dir/ -print : Run the find command to see recursive directory listing in Linux.
  3. du -a . : Execute the du command to view recursive directory listing on Unix.
Oct 1, 2022

How do I list files in ascending order in Linux? ›

Listing files by name

The easiest way to list files by name is simply to list them using the ls command. Listing files by name (alphanumeric order) is, after all, the default. You can choose the ls (no details) or ls -l (lots of details) to determine your view.

How to list all files in a directory with full path Windows? ›

Listing the full path

The command DIR /b will return just a list of filenames, when displaying subfolders with DIR /b /s the command will return a full pathname. To list the full path without including subfolders, use the WHERE command.

How do I view files in subfolders? ›

Displaying Subfolders
  1. Click on a folder if it's listed in the Navigation pane.
  2. Click on a folder in the Address bar to display its subfolders.
  3. Double-click on a folder in the file and folder listing to display any subfolders.

How do I grep in a folder and subdirectories? ›

You can make grep search in all the files and all the subdirectories of the current directory using the -r recursive search option: grep -r search_term .

How do I list all files in subdirectories? ›

By default, ls lists just one directory. If you name one or more directories on the command line, ls will list each one. The -R (uppercase R) option lists all subdirectories, recursively.

How do you get a list of the names of all files present in a directory in node JS? ›

Method 1: Using fs.

readdirSync() is a method that is available in the file system module of Node. js. It is used for reading the contents of a directory. It returns an array of file paths, buffers, or fs.

How do you get a list of the names of all files present in a directory in Javascript? ›

js fs core module to get all files in the directory, we can use following fsmethods. fs. readdir (path, callbackFunction) — This method will read all files in the directory.

How to get a list of all files in a folder and subfolders in cmd? ›

/S Displays files in specified directory and all subdirectories. /B Uses bare format (no heading information or summary).
Follow these baby steps:
  1. Press Windows + R.
  2. Press Enter.
  3. Type cmd.
  4. Press Enter.
  5. Type dir -s.
  6. Press Enter.

Which command line list all files in a directory and subdirectories? ›

The answer is to use the DIR command. This command can be used to show all files and subfolders in the current directory. In addition, it displays the file name, size, and last modification date of each file like File Explorer.

How do I select multiple files in a folder from a list of file names? ›

Click on one of the files or folders you want to select. Hold down the control key (Ctrl). Click on the other files or folders that you want to select while holding the control key. Continue to hold down the control key until you select all the files you want.

How do I use grep to search multiple files? ›

How to Grep multiple files
  1. Grep multiple files. Simply provide a list of files to search. ...
  2. Grep files in a directory. Specify the -r (recursive) flag and a directory to Grep within every file found within that directory. ...
  3. Grep within the current directory. Specify . ...
  4. Grep files with a specific file extension.
Dec 23, 2022

How do I search for a word in all files in a directory? ›

Search All Files in Directory

To search all files in the current directory, use an asterisk instead of a filename at the end of a grep command. The output shows the name of the file with nix and returns the entire line.

How to search specific text in multiple files in a directory Linux? ›

How to use the grep tool
  1. Make the search case-insensitive with the "-i" option: ...
  2. Search recursively in all files in a given directory with the "-r" option: ...
  3. Search whole words only with the "-w" option: ...
  4. Print the line numbers in which the searched word was found with the "-n" option: ...
  5. Search for multiple words syntax:
Nov 17, 2021

How do I search for a file in a directory and subdirectory in Linux? ›

Finding Files Recursively in Linux

The find command does not need flags to search the files recursively in the current directory. You only need to define the main directory and the file name using the –name option. This command will search the file within the main directory and all subdirectories.

How do I find a file in Linux from the root directory? ›

What is the find command in Linux?
  1. /path is the path where file is expected to be found. This is the starting point to search files. The path can also be / or . which represent root and current directory, respectively.
  2. -type represents the file descriptors. They can be any of the below:
Mar 17, 2022

How do I search for a file in a sub directory in Unix? ›

Search for a particular string files: find -grep

This command will search in the current directory and all sub directories. All files contaning the string passed as an argument to the grep command will have their path printed to standard output.

Is indexing the same as searching? ›

Indexing is the process by which search engines organize information before a search to enable super-fast responses to queries. Searching through individual pages for keywords and topics would be a very slow process for search engines to identify relevant information.

Why does indexing make search faster? ›

Indexing makes columns faster to query by creating pointers to where data is stored within a database. Imagine you want to find a piece of information that is within a large database. To get this information out of the database the computer will look through every row until it finds it.

How do I know if I am indexed or not? ›

Checking If Your Site is Indexed by Search Engines
  1. To see if search engines like Google and Bing have indexed your site, enter "site:" followed by the URL of your domain. ...
  2. The results show all of your site's pages that have been indexed, and the current Meta Tags saved in the search engine's index.

How do I find the top 5 files in Linux? ›

Finding the 10 Largest Linux Files on Your Drive
  1. Open a terminal.
  2. Use the du command to search all files and then use two pipes to format the returned data. du -aBM will search all files and directories, returning their sizes in megabytes. ...
  3. Press Enter to run the command.
Jun 13, 2022

How do I show files in tree command? ›

In the Windows command prompt you can use "tree /F" to view a tree of the current folder and all descending files & folders.

Which Linux commands will show the process hierarchy? ›

To list processes in Linux, use one of the three commands: ps, top or htop. Ps command provides static snapshot of all processes, while top and htop sorts by CPU usage.

How do you display hierarchy data? ›

Representing hierarchical information is quite straightforward; in the majority of cases the information designer will either use a tree diagram (or a variant of a tree diagram) or a treemap to display the data in an efficient format for the user.

What are the 5 hierarchy of data? ›

Computer Data Hierarchy: Bits, Characters, fields, records, files, database bigdata.

What command can be used to view a directory hierarchy? ›

You need to use command called tree. It will list contents of directories in a tree-like format. It is a recursive directory listing program that produces a depth indented listing of files. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn.

Which command is used to show hierarchy? ›

Pstree command in Linux that shows the running processes as a tree which is a more convenient way to display the processes hierarchy and makes the output more visually appealing. The root of the tree is either init or the process with the given pid. Pstree can also be installed in other Unix systems.

What is the hierarchy of folders? ›

A folder hierarchy is an organizational structure of one or more folders in Oracle iFS. Folder hierarchies organize the repository so that users can browse through it easily. You can create multiple folder hierarchies to organize information in different ways to make browsing convenient for different types of users.

How to check file hierarchy in Linux? ›

You need to use command called tree. It will list contents of directories in a tree-like format. It is a recursive directory listing program that produces a depth indented listing of files. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn.

What command allows the user to search for files in a directory hierarchy with versatile options? ›

Grep recursive search in all subdirectories of a directory

Grep provides a -r option for the recursive search. With this option, grep will look into all the files in the current (or specified) directory and it will also look into all the files of all the subdirectories.

How do I search for a file in a specific directory in Linux? ›

Well, surprise, surprise, you're going to need the find command in Linux to scour your directory or file system.
Basic Examples
  1. find . - name thisfile.txt. ...
  2. find /home -name *.jpg. Look for all .jpg files in the /home and directories below it.
  3. find . - type f -empty. ...
  4. find /home -user randomperson-mtime 6 -iname ".db"
Apr 5, 2021

How do I navigate a folder structure in Linux? ›

Navigate directories. Open a window, double-click on a folder, and then double-click on a sub-folder. Use the Back button to backtrack. The cd (change directory) command moves you into a different directory.

How do you view a hierarchy? ›

Start Hierarchy Viewer
  1. Connect your device to your computer. ...
  2. Open your project in Android Studio, build and run it on your device.
  3. Start Android Device Monitor. ...
  4. In the menu bar, select Window > Open Perspective, and then click Hierarchy View. ...
  5. Double-click your app's package name in the Windows tab on the left.
Dec 2, 2022

How do you display hierarchy? ›

  1. Right-click the hierarchy that you want to change, and then click Change Layout.
  2. Click Hierarchy, and then do one of the following: To show hierarchical relationships progressing from top to bottom and grouped hierarchically, click Labeled Hierarchy.

How do I grep all files recursively? ›

To recursively search for a pattern, invoke grep with the -r option (or --recursive ). When this option is used grep will search through all files in the specified directory, skipping the symlinks that are encountered recursively.

What is grep command used for? ›

The grep command can search for a string in groups of files. When it finds a pattern that matches in more than one file, it prints the name of the file, followed by a colon, then the line matching the pattern.

How to find a file in Linux in all directories and subdirectories? ›

mp4” in a directory and subdirectories? You need to use the find command on a Linux or Unix-like system to search through directories for files.
  1. -name file-name – Search for given file-name. ...
  2. -iname file-name – Like -name, but the match is case insensitive. ...
  3. -user userName – The file's owner is userName.
Dec 24, 2017


Top Articles
Latest Posts
Article information

Author: Jeremiah Abshire

Last Updated: 13/09/2023

Views: 5794

Rating: 4.3 / 5 (74 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Jeremiah Abshire

Birthday: 1993-09-14

Address: Apt. 425 92748 Jannie Centers, Port Nikitaville, VT 82110

Phone: +8096210939894

Job: Lead Healthcare Manager

Hobby: Watching movies, Watching movies, Knapping, LARPing, Coffee roasting, Lacemaking, Gaming

Introduction: My name is Jeremiah Abshire, I am a outstanding, kind, clever, hilarious, curious, hilarious, outstanding person who loves writing and wants to share my knowledge and understanding with you.