Locate, Whereis and find for file lookups

Source: Internet
Author: User

Locate non-real-time, fuzzy matching, based on the file system database to find;
UpdateDB: Generate the file database graphically, which is generated automatically at a fixed time of day, or can be generated manually using this command.
 
   
  
  1. /var/lib/mlocate/mlocate.db
 
   
  
  1. yum install -y mlocate

    The Locate command is actually another form of find-name.
Whereis
the Whereis command can only be used for program name searches, and only binary files (parameter-B), man description file (parameter-m), and source code file (parameter-s) are searched. If the argument is omitted, all information is returned.

Whereis [- sbmu ] [-SBM dir ...-f] name ...
- B: Only binary files are found;-b< directory;: Find binary files only in the directory you set ;-F: The path name before the file name is not displayed;- m: Find only documentation;-m< directory;: Find the description file only in the directory of the settings ;- S: Find only the original code file;-s< Directory > find the original code file only in the directory of the settings;-U: Finds files that do not contain the specified type.
Find real-time, accurate, and support for many search criteria
Find path to find the processing action after finding a standard lookup path: default to the current directory
Lookup criteria: Default to all files under the specified path
Handling actions: Default to show

Find standard-name "filename": Exact Match of file name
-iname "filename": Matching file names, not case-sensitive
-regex PATTERN: File lookups based on regular expressions

-user USERNAME: Searching based on the owner of a file
-group GROUPNAME:Search based on a file's genus group
-uid UID: Searching based on the UID of the file    
-gid GID: File-based GID search
Note: Deleting a user, belonging to this user-owned master file will only retain the UID number
-nouser: No Owner
-nogroup: No group

-type: Specify file type-size: Specify file size [=|-] #10k
    [=|-] #10m
   [=|-] #10gFind-size 10kWill match the content between the 9k~10k
The lookup unit for the file time is the day-atime-mtime-ctime unit is the minute-amin
-mmin
-cmin

Find the file permissions-perm mood exact Match-perm-mood file permissions are fully inclusive mood match-perm/mood any one match
Combination Lookup-A: default, can Save-o: or-not:find/tmp-not-user user1-o-type D equivalent to Find/tmp-not \ (-user user1-a-type d\)
Action-print: Display (default)
-print0: No line break display
-ls: Similar to Ls-l
-ok COMMAND{} \; User confirmation is required for each operationExample:Find-atime +5-ok mv {} {}.old \;
-exec COMMAND{} \; no user acknowledgement required
Example:Find-atime +2-exec mv {} {}.old \;
{} filename placeholder
-path PATH: Specify the path    -prune: Delete
Remove a path
 
   
  
  1. find /usr/sam      -path "/usr/sam/dir1" -prune      -o -print
  2. find [Path Expreesion]-a [ path expreesion]- o [path expreesion]
This combination of expressions can be written in pseudo-code
 
   
  
  1. if -path "/usr/sam";then
  2. -prune
  3. else
  4. -print
  5. fi




From for notes (Wiz)

Locate, Whereis and find for file lookups

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.