Linux File Find command

File Find command

1.locate:

Non-real-time, fuzzy matching, lookup is performed according to the system-wide file database;
# updatedb, Manually generated file database (fast)

2. find: Find PathFinder standard look to a future process of operation

Real-time, accurate, supports many search criteria, traversing all the files in the specified directory lookup completed, slow;

Search Path: The default search criteria to the current path: The default for all files under the specified path
Processing of operation: The default display Matching Criteria:

  -name 'FILENAME': File masterpieces exact match
     File name wildcard
         *:Any character of any length
         ?:Any single character
         []:Character any single character column
  -iname 'FILENAME': File name matching is case-insensitive
  -regex PATTERN: The file name matching based on regular expressions

  -user USERNAME: According to the owner to find
  -group GROUPNAME: Find based on group

  -uid UID: Find based on UID
  -gid GID: Find based on GID

  -nouser: Finding no owner of the file
  -nogroup: Finding no group file

  -type(file type)
      f: General files
      d
      c
      b
      l
      p
      s
  -size
     [+|-]#k
     #M
     #G

   eg. # find ./ -size +1k

Combination of conditions:

 -a and
 -o or
 -not non-

 eg. # find ./ -type d -a -name '*.txt'

 -mtime
 -ctime
 -atime 
    [+|-]#

  eg. # find ./ -atime +1

  -mmin
  -cmin
  -amin
     [+|-]#

  -perm MODE: Exact Match
        /MODE:Match any one condition
        -MODE: To display the file permissions to fully contain this mode

Operating:

 -print: display
 -ls:ls -l similar form displays detailed information about each file
 -ok COMMAND {} \; Each operation requires the user to confirm
 -exec COMMAND {} \; -ok different and does not require confirmation

 eg. # find ./ -perm -006 -exec chmod o-w {} \; 
     # find ./ -name a -ok mv {} {}.new \;

Pingbacks are closed.

Comments are closed.