linux find 模糊查找文件(名称,大小,时间,新旧)

1. 通过文件大小查找文件

find / -size +1M -type f -print              //查找根目录超过1M的文件
find -size 500c -print                 //查找当前目录等于500字节的文件
find /home -size -600k -print           //查找home目录下小于600k的文件

2. 通过文件时间查找文件

find -ctime +1 -type f -print         //查找1天前被更改过的文件
find -cmin +10 -type f -print        //查找10分钟以前状态被改变的文件
find -atime +1 -type f -print        //查找一天前被访问的文件
find -mtime -1 -type f -print        //查找1天内被更改过的文件

3. 通过文件名称查找文件

find /home -maxdepth 1 -name *.log      //查找home目录下带1og后缀名的文件(只有一层)
find /java -name *.conf      //查找java目录下名称中带有*.conf的文件(所有目录)

4. 通过文件新旧查找文件

find -newer "test.log" -type f -print            //查找比aa.txt新的文件
find ! -newer "test.log" -type f -print        //查找比aa.txt旧的文件
find -newer 'test.log' ! -newer 'test100.txt' -type f -print     //查找比aa.txt新,比bb.txt旧的文件 

版权声明:本文为JAVASCHOOL原创文章,未经本站允许不得转载。