find命令用于在Linux查找目录,文件
格式:
find 路径 选项(name,type,size,perm等)
常用选项:
-name filename:查找名为filename的文件
-type b/d/c/p/l/f:查找块设备、目录、字符、管道、符号链接、文件
-size n :查找多大的文件
-perm :按权限查找
-mtime -n(n天内) +n(n天以前) :按文件更改时间查找
-ctime -n +n:按文件创建时间查
-atiem -n +n:按文件访问时间查
-mmin -n(n分钟以内) +n(n分钟以前):按文件更改时间查
================================================
name
#查找/root/shell/目录里所有以sh结尾的文件
#查找/root/shell/目录里所有0开头的文件
#查找/root/shell/目录里以小写字母开头的文件
===================================================================
type
#查找/root/shell/目录里的目录
#查找/root/shell/里的非目录
find /root/shell/ ! -type d
#查找/root/shell/里的文件
find /root/shell/ -type f
====================================================================
size
#查找/root/里大于1M的文件(+1M),等于(1M),小于(-1M)
find /root/ -size +1M
====================================================================
perm
权限:
r=4(读)
w=2(写)
x=1(执行)
#查找/root/shell/权限为644的文件
find /root/shell/ -perm 644
===================================================================
mtime
#查找/root/shell/里,10天前的文件
find /root/shell/ -mtime +10
#查找/root/shell/里,第10天的文件
find /root/shell/ -mtime 10
#查找/root/shell/里,10天内的文件
find /root/shell/ -mtime -10