find工具 查找文件或目录

find工具

ufind工具用于查找文件或目录,根据预设的条件递归查找对应的文件

——命令格式:find  目录  条件1  选项  条件2   …

——常用条件

u-type  类型(f文件  d目录   l快捷方式) u-name  “文档名” u-iname  按名称查找忽略大小写 u-size  文件大小(k、M、G) u-user  用户名 u-mtime  按日期查找(+ 代表多少天之前   - 代表多少天之内)

— find /root/ -mtime  +10     //10天之前

— find /root/ -mtime  -10      //10天之内


ufind命令提供了一个单独的处理结果命令 –exec

——命令格式:find ..  ..  -exec  处理命令   {}    \;

u以 {} 代替每一个结果,逐个处理,遇 \;结束 ufind /var/log/ -mtime +10 -type f -exec cp {} /opt/ \;      #拷贝 ufind /var/log/ -mtime +10 -type f -exec mv {} /opt/ \;  #移动 ufind /var/log/ -mtime +10 -type f -exec rm {}  \;  #删除

猜你喜欢

转载自blog.51cto.com/11614993/2666208