Linux file Lookup command find usage collation (locate/find)

Source: Internet
Author: User

Linux file Lookup mainly includes: Locate and find

1, locate

Simple to use, based on database lookup, not real-time, usage:

Locate FILENAME

Manually updating the database (time may be longer)

UpdateDB

2. Find

Real-time, accurate, powerful, usage:

Find  Path  Lookup Standard  post-discovery action

(1) Path:. Or./both represent the current directory

(2) Search criteria:

' FILENAME '    Exact file name matching (wildcard *?) is supported. []) ' FILENAME '    file name fuzzy match (not case)-regex PATTERN      Regular match
-user USERNAME    based on owner lookup -Group group      Search by genus -uid uid-gid gid-nouser           No master File
-type    lookup based on file type -type F  file -typed  directory -type C  character device -  Type B-  block device -type L  link -type P  pipe -type s  socket
-size         lookup based on file size -size10k-size25M-size 3G-size +10k    Files larger than 10k -size-5m     files less than 5M
combination options:-a     and-o     OR-not not   
Find-mtime time    (default unit: Days)based on Times-ctime    -atime     -ctime +5      change time 5 days or more -access-3     access time within 3 days -mmin    (Default unit: minutes)-cmin-amin
find based on permissions 755     Precise permissions -perm/644     Three-bit has a match to be -perm- the    down contains (contains 600/ ..../)

Example 1: find generic files in/tmp directory without owner

Find /tmp-nouser-a-type D

Example 2: Find other files under/etc that are neither normal nor directory

find /etc-not \ (-type d-o-type f \)

(3) Post-search action

-Print    default action -LS        list -ok COMMAND \;    Need to confirm execution command-exec command \;  No need to confirm execution command

Example 3: Find all the files with permission 600 in the current directory and see their size ({} indicates the file found, \; indicates the Terminator)

Find  - du {} \;

Example 4: Find a file with a permission of 400 in the current directory and add the prefix name to the. New

Find  - mv {} {}.new \;

Linux file Lookup command find usage collation (locate/find)

Related Article

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.