find概述
可以根据文件的名称、文件大小、文件的修改时间、文件的类型、文件的权限、文件的属主属组、文件的目录层级进行查找
Find的语法:
命令 路径 选项 表达式 动作
查找 地区 妹子 18-25 约
根据文件名称查找
选项:
-name
-i
通配符
*
?
[]
[^]
[root@zzc ~]
/usr/bin/hostnamectl
/usr/share/bash-completion/completions/hostnamectl
[root@zzc ~]
/usr/bin/hostnamectl
/usr/share/man/man1/hostnamectl.1.gz
/usr/share/bash-completion/completions/hostnamectl
[root@zzc ~]
/usr/bin/hostnamectl
/usr/share/bash-completion/completions/hostnamectl
/usr/share/zsh/site-functions/_hostnamectl
[root@zzc ~]
[root@zzc ~]
/tmp/rrhostnamectlfg
/usr/bin/hostnamectl
/usr/share/man/man1/hostnamectl.1.gz
/usr/share/bash-completion/completions/hostnamectl
/usr/share/zsh/site-functions/_hostnamectl
[root@zzc ~]
[root@zzc ~]
/tmp/rrhostnamectlfg
/usr/bin/hostnamectl
/usr/share/man/man1/hostnamectl.1.gz
/usr/share/bash-completion/completions/hostnamectl
/usr/share/zsh/site-functions/_hostnamectl
[root@zzc ~]
/root/Hostnamectl
/tmp/rrhostnamectlfg
/usr/bin/hostnamectl
/usr/share/man/man1/hostnamectl.1.gz
/usr/share/bash-completion/completions/hostnamectl
/usr/share/zsh/site-functions/_hostnamectl
[root@zzc ~]
[root@zzc ~]
[root@zzc ~]
[root@zzc ~]
[root@zzc ~]
total 0
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectla
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlb
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlc
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectld
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectle
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlf
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlg
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlo
-rw-r--r-- 1 root root 0 Jul 27 17:03 hostnamectlo123
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlp
-rw-r--r-- 1 root root 0 Jul 27 17:03 hostnamectlp123
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlq
-rw-r--r-- 1 root root 0 Jul 27 17:03 hostnamectlq123
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlr
-rw-r--r-- 1 root root 0 Jul 27 17:03 hostnamectlr123
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectls
-rw-r--r-- 1 root root 0 Jul 27 17:03 hostnamectls123
-rw-r--r-- 1 root root 0 Jul 27 17:02 hostnamectlt
-rw-r--r-- 1 root root 0 Jul 27 17:03 hostnamectlt123
[root@zzc ~]
/root/test/hostnamectla
/root/test/hostnamectlb
/root/test/hostnamectlc
/root/test/hostnamectld
/root/test/hostnamectle
/root/test/hostnamectlf
/root/test/hostnamectlg
/root/test/hostnamectlo
/root/test/hostnamectlp
/root/test/hostnamectlq
/root/test/hostnamectlr
/root/test/hostnamectls
/root/test/hostnamectlt
/root/test/hostnamectlo123
/root/test/hostnamectlp123
/root/test/hostnamectlq123
/root/test/hostnamectlr123
/root/test/hostnamectls123
/root/test/hostnamectlt123
[root@zzc ~]
/root/test/hostnamectla
/root/test/hostnamectlb
/root/test/hostnamectlc
/root/test/hostnamectld
/root/test/hostnamectle
/root/test/hostnamectlf
/root/test/hostnamectlg
/root/test/hostnamectlo
/root/test/hostnamectlp
/root/test/hostnamectlq
/root/test/hostnamectlr
/root/test/hostnamectls
/root/test/hostnamectlt
[root@zzc ~]
/root/test/hostnamectla
/root/test/hostnamectlb
/root/test/hostnamectlc
/root/test/hostnamectld
[root@zzc ~]
/root/test/hostnamectla
/root/test/hostnamectlc
/root/test/hostnamectld
/root/test/hostnamectle
/root/test/hostnamectlf
/root/test/hostnamectlg
/root/test/hostnamectlo
/root/test/hostnamectlp
/root/test/hostnamectlq
/root/test/hostnamectlr
/root/test/hostnamectls
/root/test/hostnamectlt
根据文件类型查找
选项:
-type
f
d
l
s
p
b
c
[root@zzc ~]
/root/.bash_logout
/root/.bash_profile
/root/.cshrc
/root/.tcshrc
/root/.bash_history
/root/.lesshst
/root/.viminfo
/root/Hostname
/root/Hostnamectl
/root/test/hostnamectla
/root/test/hostnamectlb
/root/test/hostnamectlc
/root/test/hostnamectld
[root@zzc ~]
/root
/root/test
/root/.pki
/root/.pki/nssdb
[root@zzc ~]
/root
├── opt -> /opt/
├── .pki
│ └── nssdb
└── test
4 directories
[root@zzc ~]
/dev/log
[root@zzc ~]
/run/systemd/inhibit/1.ref
/run/systemd/sessions/1.ref
/run/systemd/initctl/fifo
[root@zzc ~]
/root/opt
[root@zzc ~]
/dev/sda3
/dev/sda2
/dev/sda1
/dev/sda
/dev/sr0
[root@zzc ~]
/dev/vsock
/dev/vcsa6
/dev/vcs6
/dev/vcsa5
[root@zzc ~]
/root/hostnamectl
根据文件的大小查找
选项:
-size
+n
-n
n
b k M G
[root@zzc ~]
/var/log/tallylog
/var/log/anaconda/ks-script-3PCKae.log
/var/log/boot.log
/var/log/firewalld
/var/log/maillog-20200726
/var/log/spooler-20200726
/var/log/spooler
/var/log/spooler-20200716
/var/log/nginx/error.log
/var/log/nginx/access.log
/var/log/spooler-20200723
[root@zzc ~]
-rw-------. 1 root root 0 Jul 6 02:13 /var/log/tallylog
[root@zzc ~]
67159586 0 -rw------- 1 root root 0 Jul 6 02:13 /var/log/tallylog
67563450 0 -rw------- 1 root root 0 Jul 6 02:17 /var/log/anaconda/ks-script-3PCKae.log
67563454 0 -rw------- 1 root root 0 Jul 27 17:35 /var/log/boot.log
67563460 0 -rw-r--r-- 1 root root 0 Jul 6 02:17 /var/log/firewalld
67588777 0 -rw------- 1 root root 0 Jul 23 03:13 /var/log/maillog-20200726
67588781 0 -rw------- 1 root root 0 Jul 23 03:13 /var/log/spooler-20200726
67588808 0 -rw------- 1 root root 0 Jul 26 03:33 /var/log/spooler
67528019 0 -rw------- 1 root root 0 Jul 6 02:14 /var/log/spooler-20200716
134348936 0 -rw-r--r-- 1 root root 0 Jul 20 19:50 /var/log/nginx/error.log
134348938 0 -rw-r--r-- 1 root root 0 Jul 20 19:50 /var/log/nginx/access.log
67113674 0 -rw------- 1 root root 0 Jul 16 03:25 /var/log/spooler-20200723
[root@zzc ~]
67160720 4 -rw-r--r-- 1 root root 193 Jul 6 02:13 /var/log/grubby_prune_debug
681834 0 drwxr-xr-x 2 root root 23 Jul 6 02:17 /var/log/tuned
714023 0 drwx------ 2 root root 23 Jul 6 02:17 /var/log/audit
67284924 0 drwxr-xr-x 2 root root 176 Jul 6 02:17 /var/log/anaconda
134317666 0 drwxr-xr-x 2 root root 6 Jul 6 02:17 /var/log/rhsm
67112876 4 -rw-r--r-- 1 root root 696 Jul 6 09:06 /var/log/vmware-network.5.log
67112867 4 -rw-r--r-- 1 root root 678 Jul 13 16:29 /var/log/vmware-network.2.log
67112878 4 -rw-r--r-- 1 root root 674 Jul 6 17:07 /var/log/vmware-network.4.log
67112882 4 -rw-r--r-- 1 root root 678 Jul 20 19:45 /var/log/vmware-network.1.log
67528018 4 -rw------- 1 root root 558 Jul 13 16:29 /var/log/maillog-20200716
134348871 0 drwxrwx--- 2 nginx root 41 Jul 20 19:50 /var/log/nginx
67588805 4 -rw------- 1 root root 186 Jul 27 16:30 /var/log/maillog
67588807 4 -rw------- 1 root root 679 Jul 27 16:30 /var/log/secure
67112916 4 -rw-r--r-- 1 root root 678 Jul 27 16:29 /var/log/vmware-network.log
[root@zzc ~]
/var/log/cron-20200726
[root@zzc ~]
67588776 20 -rw------- 1 root root 19815 Jul 26 03:33 /var/log/cron-20200726
[root@zzc ~]
75 8 -rw-r--r-- 1 root root 6085 Jul 27 16:29 /var/log/tuned/tuned.log
67113677 8 -rw------- 1 root root 6005 Jul 27 18:01 /var/log/cron
67528017 8 -rw------- 1 root root 5865 Jul 13 16:29 /var/log/secure-20200716
67112870 8 -rw-r--r-- 1 root root 5650 Jul 6 08:52 /var/log/vmware-network.9.log
67112865 8 -rw-r--r-- 1 root root 5650 Jul 9 10:36 /var/log/vmware-network.3.log
[root@zzc ~]
/var/log/anaconda/syslog
/var/log/anaconda/packaging.log
/var/log/anaconda/storage.log
/var/log/dmesg.old
/var/log/messages-20200716
/var/log/messages-20200723
/var/log/messages
/var/log/dmesg
[root@zzc ~]
67496291 276 -rw------- 1 root root 281510 Jul 6 02:17 /var/log/anaconda/syslog
67563447 112 -rw------- 1 root root 110647 Jul 6 02:17 /var/log/anaconda/packaging.log
67563448 124 -rw------- 1 root root 124184 Jul 6 02:17 /var/log/anaconda/storage.log
67112877 120 -rw-r--r-- 1 root root 122832 Jul 20 19:45 /var/log/dmesg.old
67528016 388 -rw------- 1 root root 395555 Jul 16 03:25 /var/log/messages-20200716
67113672 148 -rw------- 1 root root 148158 Jul 23 03:13 /var/log/messages-20200723
67588806 120 -rw------- 1 root root 122869 Jul 27 18:01 /var/log/messages
67112864 120 -rw-r--r-- 1 root root 122838 Jul 27 16:29 /var/log/dmesg
[root@zzc ~]
/var/log/vmware-network.8.log
[root@zzc ~]
67112873 8 -rw-r--r-- 1 root root 4127 Jul 6 09:05 /var/log/vmware-network.8.log
[root@zzc ~]
67160720 4 -rw-r--r-- 1 root root 193 Jul 6 02:13 /var/log/grubby_prune_debug
67284922 48 -rw-rw-r-- 1 root utmp 45696 Jul 27 16:30 /var/log/wtmp
67284923 8 -rw------- 1 root utmp 6912 Jul 23 12:09 /var/log/btmp
75 8 -rw-r--r-- 1 root root 6085 Jul 27 16:29 /var/log/tuned/tuned.log
67495714 28 -rw------- 1 root root 26591 Jul 6 02:17 /var/log/anaconda/anaconda.log
67496291 276 -rw------- 1 root root 281510 Jul 6 02:17 /var/log/anaconda/syslog
67563444 24 -rw------- 1 root root 21872 Jul 6 02:17 /var/log/anaconda/X.log
67563445 32 -rw------- 1 root root 29721 Jul 6 02:17 /var/log/anaconda/program.log
67563447 112 -rw------- 1 root root 110647 Jul 6 02:17 /var/log/anaconda/packaging.log
67563448 124 -rw------- 1 root root 124184 Jul 6 02:17 /var/log/anaconda/storage.log
67563449 4 -rw------- 1 root root 4017 Jul 6 02:17 /var/log/anaconda/ifcfg.log
67563456 12 -rw-r--r-- 1 root root 10054 Jul 27 16:29 /var/log/vmware-vmsvc.log
67563457 8 -rw-r--r-- 1 root root 6934 Jul 27 16:29 /var/log/vmware-vgauthsvc.log.0
67113677 8 -rw------- 1 root root 6005 Jul 27 18:01 /var/log/cron
67588778 12 -rw------- 1 root root 9327 Jul 26 03:33 /var/log/messages-20200726
67588779 16 -rw------- 1 root root 13606 Jul 24 12:11 /var/log/secure-20200726
67112873 8 -rw-r--r-- 1 root root 4127 Jul 6 09:05 /var/log/vmware-network.8.log
67112876 4 -rw-r--r-- 1 root root 696 Jul 6 09:06 /var/log/vmware-network.5.log
67112867 4 -rw-r--r-- 1 root root 678 Jul 13 16:29 /var/log/vmware-network.2.log
67588799 8 -rw------- 1 root root 8015 Jul 27 17:35 /var/log/boot.log-20200727
67112877 120 -rw-r--r-- 1 root root 122832 Jul 20 19:45 /var/log/dmesg.old
67112871 4 -rw-r--r-- 1 root root 3986 Jul 6 09:05 /var/log/vmware-network.7.log
67112878 4 -rw-r--r-- 1 root root 674 Jul 6 17:07 /var/log/vmware-network.4.log
67112882 4 -rw-r--r-- 1 root root 678 Jul 20 19:45 /var/log/vmware-network.1.log
67112913 20 -rw------- 1 root root 16395 Jul 10 03:20 /var/log/boot.log-20200710
67112924 4 -rw------- 1 root root 3925 Jul 22 08:51 /var/log/yum.log
67112866 8 -rw------- 1 root root 7969 Jul 13 17:29 /var/log/boot.log-20200713
67112869 32 -rw------- 1 root root 32040 Jul 16 03:25 /var/log/cron-20200716
67528018 4 -rw------- 1 root root 558 Jul 13 16:29 /var/log/maillog-20200716
67528016 388 -rw------- 1 root root 395555 Jul 16 03:25 /var/log/messages-20200716
67528017 8 -rw------- 1 root root 5865 Jul 13 16:29 /var/log/secure-20200716
67112870 8 -rw-r--r-- 1 root root 5650 Jul 6 08:52 /var/log/vmware-network.9.log
67491686 8 -rw------- 1 root root 8015 Jul 20 20:25 /var/log/boot.log-20200720
67113669 40 -rw------- 1 root root 37990 Jul 23 03:13 /var/log/cron-20200723
67113670 4 -rw------- 1 root root 1856 Jul 22 11:11 /var/log/maillog-20200723
67113672 148 -rw------- 1 root root 148158 Jul 23 03:13 /var/log/messages-20200723
67113673 48 -rw------- 1 root root 48914 Jul 22 12:22 /var/log/secure-20200723
67588776 20 -rw------- 1 root root 19815 Jul 26 03:33 /var/log/cron-20200726
67588805 4 -rw------- 1 root root 186 Jul 27 16:30 /var/log/maillog
67588806 120 -rw------- 1 root root 122869 Jul 27 18:01 /var/log/messages
67588807 4 -rw------- 1 root root 679 Jul 27 16:30 /var/log/secure
67112864 120 -rw-r--r-- 1 root root 122838 Jul 27 16:29 /var/log/dmesg
67112875 4 -rw-r--r-- 1 root root 3986 Jul 6 09:06 /var/log/vmware-network.6.log
67112865 8 -rw-r--r-- 1 root root 5650 Jul 9 10:36 /var/log/vmware-network.3.log
67112916 4 -rw-r--r-- 1 root root 678 Jul 27 16:29 /var/log/vmware-network.log
[root@zzc ~]
67159586 0 -rw------- 1 root root 0 Jul 6 02:13 /var/log/tallylog
67563450 0 -rw------- 1 root root 0 Jul 6 02:17 /var/log/anaconda/ks-script-3PCKae.log
67563454 0 -rw------- 1 root root 0 Jul 27 17:35 /var/log/boot.log
67563460 0 -rw-r--r-- 1 root root 0 Jul 6 02:17 /var/log/firewalld
67588777 0 -rw------- 1 root root 0 Jul 23 03:13 /var/log/maillog-20200726
67588781 0 -rw------- 1 root root 0 Jul 23 03:13 /var/log/spooler-20200726
67588808 0 -rw------- 1 root root 0 Jul 26 03:33 /var/log/spooler
67528019 0 -rw------- 1 root root 0 Jul 6 02:14 /var/log/spooler-20200716
134348936 0 -rw-r--r-- 1 root root 0 Jul 20 19:50 /var/log/nginx/error.log
134348938 0 -rw-r--r-- 1 root root 0 Jul 20 19:50 /var/log/nginx/access.log
67113674 0 -rw------- 1 root root 0 Jul 16 03:25 /var/log/spooler-20200723
[root@zzc ~]
67263633 40 -rw-r--r-- 1 root root 1946764 Jul 27 16:30 /var/log/lastlog
714345 1436 -rw------- 1 root root 1468869 Jul 27 18:01 /var/log/audit/audit.log
67563451 1520 -rw------- 1 root root 1552657 Jul 6 02:17 /var/log/anaconda/journal.log
[root@zzc ~]
-rw-r--r--. 1 root root 1.9M Jul 27 16:30 /var/log/lastlog
[root@zzc ~]
-rw-------. 1 root root 1.5M Jul 27 18:01 /var/log/audit/audit.log
[root@zzc ~]
67113676 5704 -rw-r--r-- 1 root root 5840292 Jul 27 17:56 /var/log/test.log
[root@zzc ~]
67113676 5704 -rw-r--r-- 1 root root 5840292 Jul 27 17:56 /var/log/test.log
[root@zzc ~]
/var/log/test.log
[root@zzc ~]
13+0 records in
13+0 records out
1363148800 bytes (1.4 GB) copied, 28.178 s, 48.4 MB/s
[root@zzc ~]
-rw-r--r-- 1 root root 1363148800 Jul 27 18:17 /var/log/123.log
[root@zzc ~]
-rw-r--r-- 1 root root 1.3G Jul 27 18:17 /var/log/123.log
[root@zzc ~]
67588811 1331200 -rw-r--r-- 1 root root 1363148800 Jul 27 18:17 /var/log/123.log
[root@zzc ~]
67588811 1331200 -rw-r--r-- 1 root root 1363148800 Jul 27 18:17 /var/log/123.log
根据文件的时间查找
选项:
-mtime
+n
-n
n
[root@zzc ~]
[root@zzc ~]
[root@zzc ~]
[root@zzc ~]
total 0
-rw-r--r-- 1 root root 0 Jul 10 00:00 file-10.txt
-rw-r--r-- 1 root root 0 Jul 11 00:00 file-11.txt
-rw-r--r-- 1 root root 0 Jul 12 00:00 file-12.txt
-rw-r--r-- 1 root root 0 Jul 13 00:00 file-13.txt
-rw-r--r-- 1 root root 0 Jul 14 00:00 file-14.txt
-rw-r--r-- 1 root root 0 Jul 15 00:00 file-15.txt
-rw-r--r-- 1 root root 0 Jul 16 00:00 file-16.txt
-rw-r--r-- 1 root root 0 Jul 17 00:00 file-17.txt
-rw-r--r-- 1 root root 0 Jul 18 00:00 file-18.txt
-rw-r--r-- 1 root root 0 Jul 19 00:00 file-19.txt
-rw-r--r-- 1 root root 0 Jul 1 00:00 file-1.txt
-rw-r--r-- 1 root root 0 Jul 20 00:00 file-20.txt
-rw-r--r-- 1 root root 0 Jul 21 00:00 file-21.txt
-rw-r--r-- 1 root root 0 Jul 22 00:00 file-22.txt
-rw-r--r-- 1 root root 0 Jul 23 00:00 file-23.txt
-rw-r--r-- 1 root root 0 Jul 24 00:00 file-24.txt
-rw-r--r-- 1 root root 0 Jul 25 00:00 file-25.txt
-rw-r--r-- 1 root root 0 Jul 26 00:00 file-26.txt
-rw-r--r-- 1 root root 0 Jul 27 00:00 file-27.txt
-rw-r--r-- 1 root root 0 Jul 2 00:00 file-2.txt
-rw-r--r-- 1 root root 0 Jul 3 00:00 file-3.txt
-rw-r--r-- 1 root root 0 Jul 4 00:00 file-4.txt
-rw-r--r-- 1 root root 0 Jul 5 00:00 file-5.txt
-rw-r--r-- 1 root root 0 Jul 6 00:00 file-6.txt
-rw-r--r-- 1 root root 0 Jul 7 00:00 file-7.txt
-rw-r--r-- 1 root root 0 Jul 8 00:00 file-8.txt
-rw-r--r-- 1 root root 0 Jul 9 00:00 file-9.txt
[root@zzc ~]
[root@zzc ~]
/root/.bash_logout
/root/.cshrc
/root/.tcshrc
/root/.lesshst
/root/.vimrc
/root/data/file-1.txt
/root/data/file-2.txt
/root/data/file-3.txt
/root/data/file-4.txt
/root/data/file-5.txt
/root/data/file-6.txt
/root/data/file-7.txt
/root/data/file-8.txt
/root/data/file-9.txt
/root/data/file-10.txt
/root/data/file-11.txt
/root/data/file-12.txt
/root/data/file-13.txt
/root/data/file-14.txt
/root/data/file-15.txt
/root/data/file-16.txt
/root/data/file-17.txt
/root/data/file-18.txt
/root/data/file-19.txt
[root@zzc ~]
/root/data/file-20.txt
[root@zzc ~]
/root/.bash_profile
/root/.bash_history
/root/.viminfo
/root/.bashrc
/root/data/file-21.txt
/root/data/file-22.txt
/root/data/file-23.txt
/root/data/file-24.txt
/root/data/file-25.txt
/root/data/file-26.txt
/root/data/file-27.txt
[root@zzc ~]
[root@zzc ~]
根据文件的权限查找
选项:
-perm
-421
421
/421
!
[root@zzc ~]
/root/.bash_history
/root/.viminfo
/root/data/file-24.txt
/root/data/file-25.txt
/root/data/file-26.txt
/root/data/file-27.txt
[root@zzc ~]
/root
/root/.pki
/root/.pki/nssdb
/root/data
[root@zzc ~]
[root@zzc ~]
total 0
-rw--wx-wx 1 root root 0 Jul 24 00:00 file-24.txt
-rw-r--r-- 1 root root 0 Jul 25 00:00 file-25.txt
-rw-r--r-- 1 root root 0 Jul 26 00:00 file-26.txt
-rw-r--r-- 1 root root 0 Jul 27 00:00 file-27.txt
[root@zzc ~]
data/file-25.txt
data/file-26.txt
data/file-27.txt
[root@zzc ~]
data/file-24.txt
[root@zzc ~]
data/file-26.txt
data/file-27.txt
[root@zzc ~]
total 0
-rw--wx-wx 1 root root 0 Jul 24 00:00 file-24.txt
-r--r--r-- 1 root root 0 Jul 25 00:00 file-25.txt
-rw-r--r-- 1 root root 0 Jul 26 00:00 file-26.txt
-rw-r--r-- 1 root root 0 Jul 27 00:00 file-27.txt
[root@zzc ~]
[root@zzc ~]
data/file-25.txt
data/file-26.txt
data/file-27.txt
[root@zzc ~]
[root@zzc ~]
data/file-25.txt
data/file-26.txt
data/file-27.txt
[root@zzc ~]
total 0
-rw--wx-wx 1 root root 0 Jul 24 00:00 file-24.txt
-rw-rw-rw- 1 root root 0 Jul 25 00:00 file-25.txt
-rwxr--r-- 1 root root 0 Jul 26 00:00 file-26.txt
-rw-r--r-- 1 root root 0 Jul 27 00:00 file-27.txt
[root@zzc ~]
data/file-24.txt
data/file-25.txt
data/file-26.txt
data/file-27.txt
[root@zzc ~]
[root@zzc ~]
data/file-24.txt
data/file-25.txt
data/file-26.txt
data/file-27.txt
[root@zzc ~]
total 0
--wx-wx-wx 1 root root 0 Jul 24 00:00 file-24.txt
-rw-rw-rw- 1 root root 0 Jul 25 00:00 file-25.txt
-rwxr--r-- 1 root root 0 Jul 26 00:00 file-26.txt
-rw-r--r-- 1 root root 0 Jul 27 00:00 file-27.txt
[root@zzc ~]
data/file-25.txt
data/file-26.txt
data/file-27.txt
[root@zzc ~]
201418870 24 -rws--x--x 1 root root 24048 Oct 31 2018 /usr/bin/chfn
201418873 24 -rws--x--x 1 root root 23960 Oct 31 2018 /usr/bin/chsh
201369302 32 -rwsr-xr-x 1 root root 32096 Oct 31 2018 /usr/bin/fusermount
201418745 80 -rwsr-xr-x 1 root root 78272 Oct 31 2018 /usr/bin/gpasswd
[root@zzc ~]
201368725 16 -r-xr-sr-x 1 root tty 15344 Jun 10 2014 /usr/bin/wall
201418931 20 -rwxr-sr-x 1 root tty 19624 Oct 31 2018 /usr/bin/write
201614897 376 ---x--s--x 1 root nobody 382240 Apr 11 2018 /usr/bin/ssh-agent
201682585 40 -rwx--s--x 1 root slocate 40520 Apr 11 2018 /usr/bin/locate
682454 216 -rwxr-sr-x 1 root postdrop 218632 Oct 31 2018 /usr/sbin/postdrop
[root@zzc ~]
67108936 4 drwxrwxrwt 16 root root 4096 Jul 27 2020 /tmp
187047 0 drwxrwxrwt 2 root root 6 Jul 6 02:14 /tmp/.font-unix
67284921 0 drwxrwxrwt 2 root root 6 Jul 6 02:14 /tmp/.XIM-unix
134469085 0 drwxrwxrwt 2 root root 6 Jul 6 02:14 /tmp/.ICE-unix
201458049 0 drwxrwxrwt 2 root root 6 Jul 6 02:14 /tmp/.X11-unix
根据文件的属主属组查找
选项:
-user
-group
-nouser
-nogroup
[root@zzc ~]
201696842 0 -rw-rw---- 1 ops01 mail 0 Jul 24 09:08 /var/spool/mail/ops01
67588770 0 drwx------ 2 ops01 ops01 83 Jul 24 09:10 /home/ops01
67588774 4 -rw-r--r-- 1 ops01 ops01 18 Oct 31 2018 /home/ops01/.bash_logout
67588780 4 -rw-r--r-- 1 ops01 ops01 193 Oct 31 2018 /home/ops01/.bash_profile
67588782 4 -rw-r--r-- 1 ops01 ops01 231 Oct 31 2018 /home/ops01/.bashrc
67588795 4 -rw------- 1 ops01 ops01 145 Jul 24 09:55 /home/ops01/.bash_history
820161 4 -rw-rw-r-- 1 ops01 ops_group 12 Jul 24 09:16 /data/ops01.log
[root@zzc ~]
67588770 0 drwx------ 2 ops01 ops01 83 Jul 24 09:10 /home/ops01
67588774 4 -rw-r--r-- 1 ops01 ops01 18 Oct 31 2018 /home/ops01/.bash_logout
67588780 4 -rw-r--r-- 1 ops01 ops01 193 Oct 31 2018 /home/ops01/.bash_profile
67588782 4 -rw-r--r-- 1 ops01 ops01 231 Oct 31 2018 /home/ops01/.bashrc
67588795 4 -rw------- 1 ops01 ops01 145 Jul 24 09:55 /home/ops01/.bash_history
[root@zzc ~]
67588770 0 drwx------ 2 ops01 ops01 83 Jul 24 09:10 /home/ops01
67588774 4 -rw-r--r-- 1 ops01 ops01 18 Oct 31 2018 /home/ops01/.bash_logout
67588780 4 -rw-r--r-- 1 ops01 ops01 193 Oct 31 2018 /home/ops01/.bash_profile
67588782 4 -rw-r--r-- 1 ops01 ops01 231 Oct 31 2018 /home/ops01/.bashrc
67588795 4 -rw------- 1 ops01 ops01 145 Jul 24 09:55 /home/ops01/.bash_history
[root@zzc ~]
67495942 0 --wx-wx-wx 1 ops01 ops_group 0 Jul 24 00:00 /root/data/file-24.txt
820161 4 -rw-rw-r-- 1 ops01 ops_group 12 Jul 24 09:16 /data/ops01.log
[root@zzc ~]
67495942 0 --wx-wx-wx 1 ops01 ops_group 0 Jul 24 00:00 /root/data/file-24.txt
201696842 0 -rw-rw---- 1 ops01 mail 0 Jul 24 09:08 /var/spool/mail/ops01
67588770 0 drwx------ 2 ops01 ops01 83 Jul 24 09:10 /home/ops01
67588774 4 -rw-r--r-- 1 ops01 ops01 18 Oct 31 2018 /home/ops01/.bash_logout
67588780 4 -rw-r--r-- 1 ops01 ops01 193 Oct 31 2018 /home/ops01/.bash_profile
67588782 4 -rw-r--r-- 1 ops01 ops01 231 Oct 31 2018 /home/ops01/.bashrc
67588795 4 -rw------- 1 ops01 ops01 145 Jul 24 09:55 /home/ops01/.bash_history
818813 0 drwxrws--- 3 root ops_group 121 Jul 20 10:48 /data
820160 4 -rw-r--r-- 1 root ops_group 5 Jul 24 09:14 /data/root.log
820161 4 -rw-rw-r-- 1 ops01 ops_group 12 Jul 24 09:16 /data/ops01.log
820162 4 -rw-rw-r-- 1 ops02 ops_group 6 Jul 24 09:15 /data/ops02.log
818814 0 drwxrwsr-x 2 ops02 ops_group 6 Jul 24 09:21 /data/test
820215 0 -rw-r--r-- 1 root ops_group 0 Jul 20 10:48 /data/file-20.log
[root@zzc ~]
201729427 0 -rw-rw---- 1 666 mail 0 Jul 21 16:47 /var/spool/mail/user02
201685422 0 -rw-rw---- 1 6666 mail 0 Jul 21 16:40 /var/spool/mail/user123
[root@zzc ~]
134355712 0 -rw------- 1 root 1013 0 Jul 22 11:11 /var/db/sudo/lectured/qiudao
[root@zzc ~]
[root@zzc ~]
67255910 0 -rwxr--r-- 1 1045 1047 0 Jul 26 00:00 /root/data/file-26.txt
134356976 0 drwx------ 2 1045 1047 99 Jul 24 09:16 /home/ops02
134356977 4 -rw-r--r-- 1 1045 1047 18 Oct 31 2018 /home/ops02/.bash_logout
134356978 4 -rw-r--r-- 1 1045 1047 193 Oct 31 2018 /home/ops02/.bash_profile
134356979 4 -rw-r--r-- 1 1045 1047 231 Oct 31 2018 /home/ops02/.bashrc
134356980 4 -rw------- 1 1045 1047 276 Jul 24 09:49 /home/ops02/.bash_history
134356968 4 -rw------- 1 1045 1047 637 Jul 24 09:16 /home/ops02/.viminfo
818815 0 -rw-rw-r-- 1 1045 1047 0 Jul 24 09:11 /data/ops02.txt
[root@zzc ~]
67255910 0 -rwxr--r-- 1 1045 1047 0 Jul 26 00:00 /root/data/file-26.txt
134355712 0 -rw------- 1 root 1013 0 Jul 22 11:11 /var/db/sudo/lectured/qiudao
201729427 0 -rw-rw---- 1 666 mail 0 Jul 21 16:47 /var/spool/mail/user02
201685422 0 -rw-rw---- 1 6666 mail 0 Jul 21 16:40 /var/spool/mail/user123
201696843 0 -rw-rw---- 1 1045 mail 0 Jul 24 09:08 /var/spool/mail/ops02
134356976 0 drwx------ 2 1045 1047 99 Jul 24 09:16 /home/ops02
134356977 4 -rw-r--r-- 1 1045 1047 18 Oct 31 2018 /home/ops02/.bash_logout
134356978 4 -rw-r--r-- 1 1045 1047 193 Oct 31 2018 /home/ops02/.bash_profile
134356979 4 -rw-r--r-- 1 1045 1047 231 Oct 31 2018 /home/ops02/.bashrc
134356980 4 -rw------- 1 1045 1047 276 Jul 24 09:49 /home/ops02/.bash_history
134356968 4 -rw------- 1 1045 1047 637 Jul 24 09:16 /home/ops02/.viminfo
818815 0 -rw-rw-r-- 1 1045 1047 0 Jul 24 09:11 /data/ops02.txt
820162 4 -rw-rw-r-- 1 1045 ops_group 6 Jul 24 09:15 /data/ops02.log
818814 0 drwxrwsr-x 2 1045 ops_group 6 Jul 24 09:21 /data/test
根据文件的目录层级查找
选项:
-maxdepth
[root@zzc ~]
134356976 0 drwx------ 2 1045 1047 99 Jul 24 09:16 /home/ops02
818815 0 -rw-rw-r-- 1 1045 1047 0 Jul 24 09:11 /data/ops02.txt
820162 4 -rw-rw-r-- 1 1045 ops_group 6 Jul 24 09:15 /data/ops02.log
818814 0 drwxrwsr-x 2 1045 ops_group 6 Jul 24 09:21 /data/test
[root@zzc ~]
67255910 0 -rwxr--r-- 1 1045 1047 0 Jul 26 00:00 /root/data/file-26.txt
134356976 0 drwx------ 2 1045 1047 99 Jul 24 09:16 /home/ops02
134356977 4 -rw-r--r-- 1 1045 1047 18 Oct 31 2018 /home/ops02/.bash_logout
134356978 4 -rw-r--r-- 1 1045 1047 193 Oct 31 2018 /home/ops02/.bash_profile
134356979 4 -rw-r--r-- 1 1045 1047 231 Oct 31 2018 /home/ops02/.bashrc
134356980 4 -rw------- 1 1045 1047 276 Jul 24 09:49 /home/ops02/.bash_history
134356968 4 -rw------- 1 1045 1047 637 Jul 24 09:16 /home/ops02/.viminfo
818815 0 -rw-rw-r-- 1 1045 1047 0 Jul 24 09:11 /data/ops02.txt
820162 4 -rw-rw-r-- 1 1045 ops_group 6 Jul 24 09:15 /data/ops02.log
818814 0 drwxrwsr-x 2 1045 ops_group 6 Jul 24 09:21 /data/test
find的执行的动作
-print
-ls
-delete
-exec
{}
-exec {} \;
[root@zzc ~]
/home/ops02
/data/ops02.txt
/data/ops02.log
/data/test
[root@zzc ~]
/home/ops02
/data/ops02.txt
/data/ops02.log
/data/test
[root@zzc ~]
134356976 0 drwx------ 2 1045 1047 99 Jul 24 09:16 /home/ops02
818815 0 -rw-rw-r-- 1 1045 1047 0 Jul 24 09:11 /data/ops02.txt
820162 4 -rw-rw-r-- 1 1045 ops_group 6 Jul 24 09:15 /data/ops02.log
818814 0 drwxrwsr-x 2 1045 ops_group 6 Jul 24 09:21 /data/test
[root@zzc ~]
/opt/
[root@zzc ~]
total 0
[root@zzc ~]
[root@zzc ~]
find: cannot delete ‘/opt/’: Directory not empty
[root@zzc ~]
total 4
-rw-r--r-- 1 root root 158 Jul 27 12:11 hosts
[root@zzc ~]
[root@zzc ~]
total 0
[root@zzc ~]
[root@zzc ~]
/root/data/file-24.txt
/root/data/file-25.txt
/root/data/file-26.txt
/root/data/file-27.txt
[root@zzc ~]
[root@zzc ~]
total 0
[root@zzc ~]
[root@zzc ~]
[root@zzc ~]
total 9076
-rw-r--r-- 1 root root 0 Jul 27 12:17 access.log
-rw------- 1 root root 26591 Jul 27 12:17 anaconda.log
-rw------- 1 root root 1485709 Jul 27 12:17 audit.log
-rw------- 1 root root 0 Jul 27 12:17 boot.log
-rw-r--r-- 1 root root 0 Jul 27 12:17 error.log
-rw------- 1 root root 4017 Jul 27 12:17 ifcfg.log
-rw------- 1 root root 1552657 Jul 27 12:17 journal.log
-rw------- 1 root root 0 Jul 27 12:17 ks-script-3PCKae.log
-rw------- 1 root root 110647 Jul 27 12:17 packaging.log
-rw------- 1 root root 29721 Jul 27 12:17 program.log
-rw------- 1 root root 124184 Jul 27 12:17 storage.log
-rw-r--r-- 1 root root 5840292 Jul 27 12:17 test.log
find命令跟xargs的配合
xargs
选项:
-I
[root@zzc ~]
[root@zzc ~]
total 9076
-rw-r--r-- 1 root root 0 Jul 27 12:22 access.log
-rw------- 1 root root 26591 Jul 27 12:22 anaconda.log
-rw------- 1 root root 1485709 Jul 27 12:22 audit.log
-rw------- 1 root root 0 Jul 27 12:22 boot.log
-rw-r--r-- 1 root root 0 Jul 27 12:22 error.log
-rw------- 1 root root 4017 Jul 27 12:22 ifcfg.log
-rw------- 1 root root 1552657 Jul 27 12:22 journal.log
[root@zzc ~]
[root@zzc ~]
total 9076
-rw-r--r-- 1 root root 0 Jul 27 12:23 access.log
-rw------- 1 root root 26591 Jul 27 12:23 anaconda.log
-rw------- 1 root root 1485709 Jul 27 12:23 audit.log
-rw------- 1 root root 0 Jul 27 12:23 boot.log
-rw-r--r-- 1 root root 0 Jul 27 12:23 error.log
-rw------- 1 root root 4017 Jul 27 12:23 ifcfg.log
[root@zzc ~]
[root@zzc ~]
total 9076
-rw-r--r-- 1 root root 0 Jul 27 12:24 access.log
-rw------- 1 root root 26591 Jul 27 12:24 anaconda.log
-rw------- 1 root root 1485709 Jul 27 12:24 audit.log
-rw------- 1 root root 0 Jul 27 12:24 boot.log
-rw-r--r-- 1 root root 0 Jul 27 12:24 error.log
-rw------- 1 root root 4017 Jul 27 12:24 ifcfg.log
-rw------- 1 root root 1552657 Jul 27 12:24 journal.log
[root@zzc ~]
$() == ``
[root@zzc ~]
-rw-------. 1 root root 26591 Jul 6 02:17 /var/log/anaconda/anaconda.log
-rw-------. 1 root root 4017 Jul 6 02:17 /var/log/anaconda/ifcfg.log
-rw-------. 1 root root 1552657 Jul 6 02:17 /var/log/anaconda/journal.log
-rw-------. 1 root root 0 Jul 6 02:17 /var/log/anaconda/ks-script-3PCKae.log
-rw-------. 1 root root 110647 Jul 6 02:17 /var/log/anaconda/packaging.log
-rw-------. 1 root root 29721 Jul 6 02:17 /var/log/anaconda/program.log
[root@zzc ~]
[root@zzc ~]
total 0