Find: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 4: Line 4:


=Usage=
=Usage=
==Numeric Arguments=
All numeric arguments are interpreted as follows:
* +n for greater than n
* n for exactly n
* -n for less than n


==Target Type==
==Target Type==
Line 47: Line 55:
==Time Constraints==
==Time Constraints==


All numeric arguments are interpreted as follows:
+n for greater than n
n for exactly n


-n for less than n





Revision as of 02:53, 27 December 2017

Internal

Usage

=Numeric Arguments

All numeric arguments are interpreted as follows:

  • +n for greater than n
  • n for exactly n
  • -n for less than n

Target Type

find . -type <type-identifier>

where the type identifier can be:

  • f regular file
  • d directory
  • l symbolic link
  • b block special
  • c character special
  • p FIFO
  • s socket

Case Insensitive Search

find . -iname ...

Control Descend Depth

The upper and lower limit of the descend depth can be controlled with -mindepth and -maxdepth, as follows:

find . -mindepth n

Configure find to apply tests and action at levels equal or deeper than n. -mindepth 1 processes the content of the directory specified as argument and recursively the content of its sub-directories.

find . -maxdepth n

Configure find to descend at most n directory levels below the command line arguments. -maxdepth 0 limits the whole search to the command line arguments.

In order to access directory between an upper and lower depth limit, both -mindepth and -maxdepth should be used.

Time Constraints

Time flags:

  • -amin n - file was accessed n minutes ago.
  • -anewer file - file was accessed more recently than file was modified.
  • -atime n - file was accessed n * 24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, the fractional part is ignored, so to match -atime + 1, a file has to have been accessed at least two days ago.
  • -cmin
  • -cnewer file
  • -ctime
  • -mmin n -
  • -mtime

Find all files modified less that 2 days ago

find . -mtime -2

-name Patterns

A pattern for file names with specific characters on specific positions can be specified with [...]:

find . -name *.[jw]ar

looks for *.jar and *.war.

Mac Detail

On Mac, the pattern must be specified between quotes:

find . -name "*.something"