用于文件查找shell
·find /path -
-type 基于类型 f d s c b l 文件类型 find /etc -type f -name "ifc*" [root@localhost mnt]# find /etc -type f -name "ifc*" /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-ens33 -size 基于大小 +5M 大于5M的文件 5M 等于5M的文件 -5M 小于5M的文件 find /etc -type f -size +100K | xargs ls -hl 显示大于100k的文件 -mtime 基于时间 +7 7天之前 7 第7天 -7 最近7天 find /etc -type f -name "file-*" -mtime +7 |xargs rm -f 保留最近7天的文件,删除7天之前的文件 -user 基于用户 -group 基于组 find /home -user jack 在目录下找到属主jack的文件 find /home -group jack 在目录下找到属组的文件 -nouser -nogroup 查找没有属主或则属组的文件 -a 而且 -o 或者 # -nouser -a -nogroup -delete 删除 -ok 后面跟自定义shell命令(会提示是否操做) -exec 逐个执行但不会提示 find -type f -name "file*" -exec cp -rv {} /tmp \; 同 find -type f -name "file*" | xargs cp -rvf /tmp/ -exec后面跟着shell命令 cp -rv {} /tmp {}就是find找到的东西,就是参数 /tmp 复制到的地方 \;是固定搭配 ! 取反
### 过滤code
·find ./ -type f |xargs grep "XX" 从文件中找到写有XX的文件