find command in linux


Find command


Purpose


find command searches for files in a directory hierarchy

USAGE


find options starting/path expression

Description: 


This can be extended as:

• The -H, -L and -P options control the treatment of symbolic links.

• If no paths are given, the current directory is used.

• If no expression is given, the expression -print is used.

OPTIONS:


The five `real' options -H, -L, -P, -D and -O must appear before the first path name, if  at
all.

• -P     Never follow symbolic links.

• -L     Follow symbolic links.

• -H     Do not follow symbolic links, except while processing the command line arguments.

-D debugopts


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.

Valid debug options include

  • help   Explain the debugging options



  • tree   Show the expression tree in its original and optimised form.



  • stat   Print messages as files are examined with the stat and lstat system calls.



  • opt    Prints diagnostic information relating to the optimisation of the expression tree;



  • o rates  Prints a summary indicating how often each predicate succeeded or failed.


   -Olevel


It enables query optimisation.

The optimisations performed at each optimisation level are as follows.

              0      Equivalent to optimisation level 1.

              1     This  is  the  default optimisation level

              2      Any -type or -xtype tests are performed after any tests

              3      the full cost-based query optimiser is enabled.

EXPRESSION


The part of the command line after the list of starting points is the expression.

 An expression is composed of a sequence of things:

• Tests: Tests return a true or false value

• ActionsActions have side effects and return either true or false, usually based

• Global options: It affects the operation of tests and actions specified on any part.
Global options always return true.

• Positional options:   Positional options affect only tests or actions which follow them.
Positional options always return true.

Operators


Operators join together the other items within the expression.  They include for example -o (meaning logical OR) and –a (meaning logical AND).

Where an operator is missing, -a is assumed.

If the whole expression contains no actions other than -prune or -print, -print is performed on all files for which the whole expression is true.


       The -delete action also acts as an option.

Basic Examples



Comments