Find the file compression locate find

1 locate Find files using updatedb establish mlocate.db entire disk file search indexing disk performance.
locate -i case-insensitive
locate -n list only the top n
locate -r "(jpg | png) . $" Find jpg or png file to support the end of j basic regular expressions

2 find 实时搜索 默认递归搜索
   find  [OPTION] ...[查找路径] [查找条件][处理动作]

find / etc -name passwd --- find + l + path to specify the file name

[23:42:14 scripts37 the root @ localhost] $ Find / etc / -maxdepth 1 -name the passwd
/ etc / ---- maxDepth the passwd present embodiment to specify a search hierarchy / etc / directory search for one layer at passwd.

find /etc/ -maxdepth 2 -mindepth 2 -name filename 搜索最多到第二层 最少搜索第二层只搜索第二层

[23:54:08 root@localhost ~]$find /data -depth  先列出文件再列出文件夹 排列有变化

/data/scripts37.tar
/data/scripts37/diskcheck1026.sh
/data/scripts37/creatuseradd.sh
/data/scripts37/read23.sh
。。。。。。。。。。。
/data/f1.txt
/data/dir/f1
/data/dir
/data/f2
/data

-name support wildcards, such as: -name "* .jpg"
-iname "File Name": is not case sensitive

-inum n 按照inode号查找
[00:02:27 root@localhost data]$ll -i
total 68
100663360 drwxr-xr-x. 2 root root 16 Feb 16 23:51 dir
69 -rw-r--r--. 1 root root 0 Feb 16 20:51 f1.txt
85 -rw-r--r--. 1 root root 595 Feb 16 23:51 f2
68 drwxr-xr-x. 2 root root 4096 Feb 16 23:13 scripts37
67 -rw-r--r--. 1 root root 61440 Feb 16 08:17 scripts37.tar
33554496 drwxr-xr-x. 3 root root 19 Feb 16 15:28 test
[00:02:33 root@localhost data]$find /data/ -inum 70
/data/scripts37/diskcheck1026.sh

-samefile name 相同的inode号的文件
[00:06:25 root@localhost data]$ll -i
total 72
100663360 drwxr-xr-x. 2 root root 16 Feb 16 23:51 dir
69 -rw-r--r--. 1 root root 0 Feb 16 20:51 f1.txt
85 -rw-r--r--. 2 root root 595 Feb 16 23:51 f2
85 -rw-r--r--. 2 root root 595 Feb 16 23:51 f2.link
68 drwxr-xr-x. 2 root root 4096 Feb 16 23:13 scripts37
67 -rw-r--r--. 1 root root 61440 Feb 16 08:17 scripts37.tar
33554496 drwxr-xr-x. 3 root root 19 Feb 16 15:28 test
[00:06:35 root@localhost data]$find /data/ -samefile /data/f2
/data/f2
/data/f2.link
[00:07:08 root@localhost data]$

-link n n is the number of links to a file
- regex "PSTTERN": PATTERN to match the entire file path. Rather than the file name
00:10:50 root @ localhost data] $ find / usr / share / pixmaps / -regex ". *. Jpg $" --- complete path match

[00:13:17 root @ localhost data] $ find / -user zhonghua -ls - Search by user zhonghua files ls lists the file attributes.

find / -nouser ---- look no master file

find /etc -type d 搜索、etc下的文件夹
find 、dev -type b 搜索块文件
    find /data -empty -ls   搜索空文件 大写为零
    [00:22:44 root@localhost data]$find /data/ -empty -ls

67160128 0 drwxr-xr-x 2 root root 6 Feb 16 15:28 /data/test/test1
69 0 -rw-r--r-- 1 root root 0 Feb 16 20:51 /data/f1.txt

    find /data  ! -empty -ls 搜索非空文件                !逻辑取反
        find /data  -not  -empty -ls 搜索非空文件        

Support logical condition
with: -a
or: -o
non-:! -Not
! #Find / -ls ----- check the Data -empty non-empty files and folders
#find / data -not -empty -ls --- - Charles non-empty files and folders in
the Find / -name the Data "f " -a The -type f Find names starting with f and is an ordinary file and is the default mode -a can omit
the Find / -name the Data "f
" -o The -type f Find names starting with f or ordinary file

find / data (-name "f *" -o -type f) -a ls - -a default is yes and the logic high priority in order not to mistake the brackets enclose command execution priority needs to escape before execution.

~ # Find / etc -name "* .conf" --- "" avoid errors

# Exclude search
#find / etc -path '/etc/sane.d' -a -prune -o -name " .conf" -a --- and after -prune Cut Cut etc / sane.d / directory go Search under / etc .conf file.
* The Find / etc (-path "/etc/sane.d" -o "/ etc / Fonts") -a -prune -o -name " .conf" under search / etc besides, etc / sane.d and folders , etc / fonts folder of files ending in .conf **

[03:22:12 root @ localhost data] $ dd if = / dev / zero of = f1 bs = 1 count = 10240 - create a file f1 uppercase 10K bs = 1 (1 byte) is 1024 bytes 1K, 10240 bytes 10K
10240 0 + Records in
10240 + 0 OUT Records
10240 bytes (10 kB) copied appears, 0.140448 S, 72.9 kB / S
[03:23:35 the root @ localhost Data] $ LL F1
-rw-r-- r--. the root. 1 the root On Feb. 17 03:23 10240 F1
[03:23:41 the root @ localhost Data] Find -size $ 10K
./f1
[03:24:06 the root @ localhost Data] $

#find / etc / -size 6k {5 between uppercase lookup file to 6K}
#find / etc / -szie -6K {} lookup file between 0-5K
#find / etc / -size +. 6K to find larger than { 6k file}

find -atime (the default is days) +10 10 days previous file

#find -atime -10 file within 10 days

find -atime 10 to find files between the tenth day of the tenth day does not write to the current path of the default path

find -perm 644 644 to find the current file permissions exact match

[04:14:25 root @ localhost data] $ find / data / scripts37 -perm / 622 -ls fuzzy matching / 622 is the owner of your group and the other as long as there is a match to check out.

[04:17:32 root@localhost data]$find -perm -222

./f2.link ------------------ -222 in "" - "" means the owner and owning group and other should have write permission
[04:17: the root localhost Data @ 49] $ LL
Total 80
drwxr-XR-X. On Feb 16 16 2 23:51 the root the dir the root
drwxr-XR-X. On Feb 2. 6. 17 00:23 the root the root dir2
-------- -.. 1 the root the root On Feb. 17 03:23 10240 F1
-rw-R & lt -. r-- the root. 1 0 On Feb 16 20:51 f1.txt the root
-rw-R & lt -. r-- On Feb. 1 the root the root 595 23:51 F2 16
. lrwxrwxrwx the root. 1 f2.link the root. 8 On Feb. 17 00:08 -> / Data / F2

Equivalent command

[04:37:54 root@localhost data]$find -perm -001 -fls /data/flog2.log

[04:38:24 root@localhost data]$find -perm -001 > /data/ls.log

[04:42:48 root @ localhost data] $ find -perm / 001 -ok chmod o + w {} \; to find the file and modify the permissions to do "{}" must get search results -ok "\;" the end of grammar Claim


















< chmod ... ./fid > ? y

[04:48:55 root @ localhost data] $ find -perm / 002 -exec ls -l {} \; exec place directly results not prompt OK

total 72
drwxr-xrwx. 2 root root 16 Feb 16 23:51 dir
drwxr-xrwx. 2 root root 6 Feb 17 00:23 dir2
-rw-r--r--. 1 root root 0 Feb 16 20:51 f1.txt
drwxr-xrwx. 2 root root 6 Feb 17 00:35 fid
-rw-r--r--. 1 root root 1540 Feb 17 04:38 flog2.log
-rw-r--r--. 1 root root 325 Feb 17 04:42 ls.log
drwxr-xrwx. 2 root root 4096 Feb 16 23:13 scripts37
-rw-r--r--. 1 root root 61440 Feb 16 08:17 scripts37.tar
drwxr-xrwx. 3 root root 19 Feb 16 15:28 test

[04:52:44 root@localhost data]$find / -size +10M -exec ls -lh {} \;

-rw-------. 1 root root 71M Dec 14 08:29 /boot/initramfs-0-rescue-c8f47886da6d4ec687a38cc0be7425b1.img
-rw-------. 1 root root 28M Dec 14 08:31 /boot/initramfs-3.10.0-957.el7.x86_64.img
-rw-------. 1 root root 11M Dec 14 08:32 /boot/initramfs-3.10.0-957.el7.x86_64kdump.img

Guess you like

Origin blog.51cto.com/12246080/2472063