find命令的日常用法

find ./ -size +2048c //查找大于2k的文件
find ./ -size -2048c //查找小于于2k的文件
ls -l |grep "^-"|wc -l  //统计多少个文件
ls -l |grep "^d"|wc -l //统计多少个文件夹
ls -lR|grep "^d"|wc -l //统计多少个文件夹(包括子目录里的)

find . -type d -name ".git" -print   //查询CVS目录并打印出来.
find . -type d -name ".git" -exec rm -fr {} \;  //查询CVS目录并执行删除操作。
find . -type f -name ".gitignore" -exec rm -fr {} \;

        find ./ -mtime 1 -type f      #查找48小时~24小时内最新修改过的文件
        find ./ -mtime 0 -type f      #查找24小时内最新修改过的文件
        find ./ -mtime 0 -o -mtime 1 -o -mtime 2 -type f    #查找最新三天修改过的最新文件
        find ./ -mtime +30 -type f -exec rm -fr {} \;     #查找并删除30天以前修改过的文件
        find ./ -name "access_2018*" -mtime +30 -type f -exec rm -fr {} \;          #查找并删除30天以前名字格式为access_2018*修改过的文件
        find ./ -mmin -30 -type f | head -1     查找30分钟内最新修改过的文件
        find ./ -mmin -30 -type f |tail -1      #查找30分钟内最早修改过的文件 

猜你喜欢

转载自blog.csdn.net/mcuhome/article/details/80934665