find查找命令,find查找


find

# 格式 find [路径] [参数] [表达式] -exec 指令 {} \ ;
-{} 代表find找到的文件
-\ 禁止转意 ; 表示本行指令结束
# find /sbin -type f -size +1M -exec ls {} \;
--在/sbin目录中查找文件类型为常规文件并且文件大小大于1M,再使用ls命令来查看找到的文件的类型
# find /sbin -type f -size +1M -exec cp {} /tmp \;

参数:

  -name 按照文件名查找文件。
#find / -name "*.conf"

-perm 按照文件权限来查找文件。
#find / -perm 755 || find /tmp -perm 755 -ls

-user 按照文件属主来查找文件.
#find / -user student

-group 按照文件所属的组来查找文件。
#find / -group student

# find / -user vip01 ! -group upl_vip

-newer file1 ! file2 查找更改时间比文件file1新但比文件file2旧的文件。
#find /home/ -newer kk

-type 查找某一类型的文件,诸如:
b- 块设备文件。d - 目录。c - 字符设备文件。 p - 管道文件。l - 符号链接文件。f - 普通文件。
#find /dev/ -type b -ls

-size n:[c] 查找文件长度为n块的文件,带有c时表示文件长度以字节计。
find /etc/ -size 585c c代表字符 -585c 小于 +566c大于
find /tmp/ -size 2 大于2块 -2小于2块

相关内容