zoukankan      html  css  js  c++  java
  • 文件查找 find

    find查找工具

    • 文件查找
      • 文件名称
        • find ./ -name ""  名称查找
        • find ./ -iname ""  忽略大小写
      • 文件大小
        • find ./ -size +5M  查找大于5M的文件
        • find ./ -size -5M  查找小于5M的文件
        • find ./ -size  5M  查找等于5M的文件
      • 文件类型
        • find -type f   查找类型为文件的
        • find -type d  查找类型为目录的
        • find -type f   查找类型为文件的
        • find -type s   查找类型为socket的
        • find -type c   查找类型为字符设备
        • find -type b  查找类型为块设备
        • find -type l   查找类型是链接文件
      • 文件权限
        • find ./ -perm 644  查找文件权限为644
        • find ./ -perm -644  查找文件权限包含644权限的文件
        • find ./ -perm [4000|2000|1000] 查找文件权限为suid sgid sticy
      • 用户与组
        • find ./ -user root 查找文件属主为root
        • find ./ -group root 查找文件属组为root
        • find ./ -user root -a -group root 查找文件属主和属组都为root
        • find ./ -user root -o -group root 查找文件属主或属组为root
      • 文件时间
        • find ./ -mtime +7 查找7天之前的
        • find ./ -mtime -7 查找最近7天的
        • find ./ -mtime +7 查找往前数第7天的
        • 实例
          • find /var/ -type f -iname "*.log" -mtime +7 | xargs rm -f
          • find /var/ -type f -iname "*.log" -mtime +7 -exec rm -f {} ;
          • find /var/ -type f -iname "*.log" -mtime +7 -delete
    • 处理动作
      • 打印
        • -print 默认打印
        • -ls 以长格式显示
      • 删除
        • -delete 删除查找出的文件,不能删除目录
      • 执行命令
        • -ok 执行shell命令但会提示
        • -exec 执行shell命令
          • 实例
            • find /var/ -type f -iname "*.log" -mtime +7 -exec cp -rfv {} /tmp ; 复制
            • find /var/ -type f -iname "*.log" -mtime +7 -exec mv {} /tmp ; 移动
            • find /var/ -type f -iname "*.log" -mtime +7 -exec rm -f {} ; 删除
        • xargs
          • 实例
            • find /var/ -type f -iname "*.log" -mtime +7 | xargs rm -f 删除
            • find /var/ -type f -iname "*.log" -mtime +7 | xargs cp -rft /tmp 复制
            • find /var/ -type f -iname "*.log" -mtime +7 | xargs mv -t /tmp 移动
            • find /var/ -type f -iname "*.log" -mtime +7 | xargs -l {} cp -rf {} /tmp 复制(不常用)
            • find /var/ -type f -iname "*.log" -mtime +7 | xargs -l {} mv {} /tmp 移动(不常用)
      • 命令参数
  • 相关阅读:
    python_django_sae入口配置
    Python_问题收录总结
    python_不用循环打印1-1000
    python_程序模拟浏览器请求及会话保持
    python_socket
    【SIGGRAPH】【最终幻想XV】的战斗场景实时演示的要点解说
    【SIGGRAPH】最终幻想15的渲染技术
    【SIGGRAPH】用【有说服力的照片真实】技术实现最终幻想15的视觉特效
    罪恶装备 Xrd REVELATOR 3D进化出的非照片真实视觉
    《最终幻想XV》中角色AI的意识决策系统解析
  • 原文地址:https://www.cnblogs.com/jascky/p/8496071.html
Copyright © 2011-2022 走看看