linux下find查找命令用法

2020-01-30 12:30:43王旭

find     /    -atime    -2           # 查找在系统中最后48小时访问的文件
find     /    -empty                # 查找在系统中为空的文件或者文件夹
find     /    -group    cat          # 查找在系统中属于 groupcat的文件
find     /    -mmin    -5           # 查找在系统中最后5分钟里修改过的文件
find     /    -mtime    -1          #查找在系统中最后24小时里修改过的文件
find     /    -nouser               #查找在系统中属于作废用户的文件
find     /    -user     fred         #查找在系统中属于FRED这个用户的文件

查当前目录下的所有普通文件
-------------------------------------------------------------------------------- # find . -type f -exec ls -l {} ;
-rw-r--r--      1 root       root          34928 2003-02-25    ./conf/httpd.conf
-rw-r--r--      1 root       root          12959 2003-02-25    ./conf/magic
-rw-r--r--      1 root       root            180 2003-02-25    ./conf.d/README
查当前目录下的所有普通文件,并在- e x e c选项中使用ls -l命令将它们列出
=================================================
在/ l o g s目录中查找更改时间在5日以前的文件并删除它们:
$ find logs -type f -mtime +5 -exec    -ok    rm {} ;
=================================================
查询当天修改过的文件
[root@book class]# find    ./    -mtime    -1    -type f    -exec    ls -l    {} ;
=================================================
查询文件并询问是否要显示
[root@book class]# find    ./    -mtime    -1    -type f    -ok    ls -l    {} ;  
< ls ... ./classDB.inc.php > ? y