find
Path where the command: / bin / find
Execute permissions: All users
Syntax: find [search] [matching condition]
Description: File Search
Parameter Description
1. -name based on the file name to search for
find / -name log lists only the log file named file *
the Find / -name " log " lists the file name contains the log *
support for regular expressions, but must be quoted * Use quotation marks
to match any number of characters ,? matches any single character *
-iname not case-sensitive **
$find ./ -name "*md*"
内容太多
$find / -iname js
2. -size Find based on file size
+ n is greater than
-n less than
n equal to
n indicates the size, in units of data block size 1 = 0.5k
$ find ./ +1024 #搜索当前目录下大于1M的文件
3.-user according to the owner to find
-user according to the owner to find
-grop according to your group to find
4. The time attribute to find
-amin access time Access
-cmin file attributes Change
-mmin modify the file contents
$find /etc -cmin -5 #在etc/目录下查找5分钟内被修改过的属性的文件和目录 #如果是大于5分钟就是+5
5. Look for a file type
-type find the file type
f file d directory l soft link file
-inum according to find the i-node
$ sudo find /etc -name init* -a -type f #在/etc下查找名字以init开头的文件
[sudo] feng 的密码:
/etc/kernel/postrm.d/initramfs-tools
/etc/kernel/postinst.d/initramfs-tools
/etc/initramfs-tools/initramfs.conf
6. usual connectivity options
$ find /etc -size +163840 -a -size -204800 #在/etc下查找大于80MB小于100MB的文件
-a 即为and,两个条件同时满足
-o 即为or,两个条件满足其一即可
$ find /etc -name inittab -exec ls -l {} \; #在/etc下查找inittab文件并显示其详细信息
#-exec/-ok 命令{} \; 对搜索结果执行操作,-ok会一个一个的询问你是否要查看,y 和n
$ sudo find /etc -name init* -a -type f -exec ls -l {} \;
-rwxr-xr-x 1 root root 821 2月 12 20:29 /etc/kernel/postrm.d/initramfs-tools
-rwxr-xr-x 1 root root 868 2月 12 20:29 /etc/kernel/postinst.d/initramfs-tools
-rw-r--r-- 1 root root 1107 2月 12 20:29 /etc/initramfs-tools/initramfs.conf