Linux file Lookup (find,locate)

Source: Internet
Author: User

File Lookup:Locate:non-real-time, fuzzy matching, lookup is based on the system-wide file database;# UpdateDB, manually generate the file databaseFast Speed Find:Real TimePrecisesupport for many search criteriatraverse all files in the specified directory to complete the lookup, slow;      Find Find Path lookup criteria lookup to future processing operationsFind path: Default to current directoryLookup criteria: Default to all files under the specified pathprocessing operation: default is Display Matching Criteria:-name ' FILENAME ': exact matching of file masterpiecesfile name wildcard:*: Any character of any length                  ?                  []-iname ' filename ': file name matching is case insensitive-regex PATTERN: file name matching based on regular expressions      -user USERNAME: Based on owner lookup-group GROUPNAME: Search by genus Group      -uid UID: Search by UID-gid GID: Search by GID      -nouser: Finding files that are not owned by the master-nogroup: Finding files that are not owned by a group      -typef: Normal fileDCbLPs      -size [+|-]#k#M#G/ tmp directory, not a directory, and a file that is not a socket type/tmp/test Directory, the owner is not user1, nor user2 files; -mtime Modification Time-ctime-atime Access Time            [+|-]#-mmin-cmin-amin            [+|-]#Explanation-atime 5 means that the-atime +5, which is just five days away from the moment, means that the-atime-5, which is more than five days away, represents a visit within five days from now.            -perm MODE: Exact Match/mode: Any one match that satisfies the condition-mode: File permissions can fully contain this MODE only when the condition is met            -644644:rw-r--r--755:rwxr-xr-x750:rwxr-x---find./-perl-001Operation:-print: Display-ls: Displays the details of each file in a form similar to Ls-l-ok COMMAND {} \; User confirmation is required for each operation-exec COMMAND {} \;Example of operation: {} indicates the match to the content [[email protected] scripts]# find. -amin-30-exec chmod u-w {} \; [[email protected] scripts]# lltotal 20-rwxr-xr-x 1 root root 280 jan  7 11:55 1.sh-r--r--r--1 root root   0 jan  8 08:03 a-rwxr-xr-x 1 root root 168 jan  7 11:13 jiou_sum.sh-rwxr-xr-x 1 root root 261 jan  8 03:30 sum.sh-rwxr-xr-x 1 root root 222 jan  7 17:42 user01.sh-rwxr-xr-x 1 root root 489 jan  7 18:24 User.sh[[em Ail protected] scripts]# find. -amin-30-ok chmod u+w {} \;< chmod .... >? y< chmod .... A >? Y[[email protected] scripts]# lltotal 20-rwxr-xr-x 1 root root 280 jan  7 11:55 1.sh-rw-r--r--1 root root   0 jan  8 08:03 a-rwxr-xr-x 1 root root 168 jan  7 11:13 jiou_sum.sh-rwxr-xr-x 1 root root 261 jan  8 03:30 sum.sh-rwxr-xr-x 1 root root 222 jan  7 17:42 user01.sh-rwxr-xr-x 1 root root 489 jan  7 18:24 user.sh Change file Name: [[email protected] scripts]# find -perm 644./a[[emaIl protected] scripts]# find -perm 644-exec mv {} {}.new \; [[email protected] scripts]# lltotal 20-rwxr-xr-x 1 root root 280 jan  7 11:55 1.sh-rw-r--r--1 root root   0 jan  8 08:03 a.new-rwxr-xr-x 1 root root 168 jan  7 11:13 jiou_sum.sh-rwxr-xr-x 1 root root 261 Jan&nbsp ; 8 03:30 sum.sh-rwxr-xr-x 1 root root 222 jan  7 17:42 user01.sh-rwxr-xr-x 1 root root 489 jan  7 18:24 USER.SH&N BSP; another example: Find and append files larger than 1M to/tmp/etc.largesfile [[email protected] scripts]# find/etc/-size +1m/etc/pki/tls /certs/ca-bundle.trust.crt/etc/selinux/targeted/policy/policy.24/etc/selinux/targeted/modules/active/ Policy.kern[[email protected] scripts]# find/etc/-size +1m |xargs >>/tmp/etc.largesfile[[email  Protected] scripts]# cat/tmp/etc.largesfile/etc/pki/tls/certs/ca-bundle.trust.crt/etc/selinux/targeted/policy/ Policy.24/etc/selinux/targeted/modules/active/policy.kern[[email protected] scripts]# find/etc/-size +1M- Exececho {} >>/tmp/etc.largesfile \;                    [[email protected] scripts]# cat/tmp/etc.larges file/etc/pki/tls/certs/ca-bundle.trust.crt/etc/selinux/targeted/policy/policy.24/etc/selinux/targeted/modules/ active/policy.kern/etc/pki/tls/certs/ca-bundle.trust.crt/etc/selinux/targeted/policy/policy.24/etc/selinux/ targeted/modules/active/policy.kern##############################################################[[email  Protected] scripts]# stat a  File: ' A '   size:0               blocks:0& nbsp         IO block:4096   regular empty filedevice:fd00h/64768d    INODE:131939&N Bsp     links:1access: (0644/-rw-r--r--)   Uid: (    0/    root)    gid: (  & nbsp 0/    root) access:2017-01-08 08:03:12.990058301 +0800modify:2017-01-08 08:03:07.122074618 +0800Change: 2017-01-0808:03:12.990058301 +0800 [[email protected] scripts]# find-amin-5-ls143757    4 drwxr-xr-x   2 root     root         4096 jan  8 08:03 .131939    0-rw-r- -r--   1 root     root            0 jan  8 08:03/a[[email&nb Sp;protected] scripts]# find-atime-5-ls143757    4 drwxr-xr-x   2 root    &NBSP;ROOT&NBSP ;        4096 jan  8 08:03 .131939    0-rw-r--r--   1 root      root            0 jan  8 08:03 ./a140442    4-rwxr-xr-x   1 ROOT&N Bsp    root          168 jan  7 11:13 ./jiou_sum.sh140514    4-RWXR-XR-X&NB Sp  1 root     root          222 jan  7 17:42 ./user01.sh140515  &nbsp ; 4-rwxr-xr-x&nbsp  1 root     root          261 jan  8 03:30 ./sum.sh140448    4 -rwxr-xr-x   1 root     root          280 jan  7 11:55/1.sh14051 3    4-rwxr-xr-x   1 root     root          489 jan  7 1 8:24./user.sh

Linux file Lookup (find,locate)

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.